Class: MAuth::Faraday::MAuthClientUserAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/mauth/faraday.rb

Overview

add MAuth-Client’s user-agent to a request

Instance Method Summary collapse

Constructor Details

#initialize(app, agent_base = 'Mauth-Client') ⇒ MAuthClientUserAgent

Returns a new instance of MAuthClientUserAgent.



93
94
95
96
# File 'lib/mauth/faraday.rb', line 93

def initialize(app, agent_base = 'Mauth-Client')
  @app = app
  @agent_base = agent_base
end

Instance Method Details

#call(request_env) ⇒ Object



98
99
100
101
102
# File 'lib/mauth/faraday.rb', line 98

def call(request_env)
  agent = "#{@agent_base} (MAuth-Client: #{MAuth::VERSION}; Ruby: #{RUBY_VERSION}; platform: #{RUBY_PLATFORM})"
  request_env[:request_headers]['User-Agent'] ||= agent
  @app.call(request_env)
end