Class: MusicBrainz::Middleware

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/musicbrainz/middleware.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/musicbrainz/middleware.rb', line 4

def call(env)
  env[:request_headers].merge!(
    "User-Agent" => user_agent_string,
    "Via"        => via_string
  )
  @app.call(env)
end

#configObject



20
21
22
# File 'lib/musicbrainz/middleware.rb', line 20

def config
  MusicBrainz.config
end

#user_agent_stringObject



12
13
14
# File 'lib/musicbrainz/middleware.rb', line 12

def user_agent_string
  "#{config.app_name}/#{config.app_version} ( #{config.contact} )"
end

#via_stringObject



16
17
18
# File 'lib/musicbrainz/middleware.rb', line 16

def via_string
  "gem musicbrainz/#{VERSION} (#{GH_PAGE_URL})"
end