Class: Omniauth::Pixiv::Faraday::Request::UserAgent

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/omniauth-pixiv/faraday/request/user_agent.rb

Constant Summary collapse

DEFAULT_USER_AGENT =
"omniauth-pixiv/#{Omniauth::Pixiv::VERSION}"

Instance Method Summary collapse

Constructor Details

#initialize(app, user_agent) ⇒ UserAgent

Returns a new instance of UserAgent.



10
11
12
13
# File 'lib/omniauth-pixiv/faraday/request/user_agent.rb', line 10

def initialize(app, user_agent)
  @user_agent = user_agent
  super(app)
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/omniauth-pixiv/faraday/request/user_agent.rb', line 15

def call(env)
  env.request_headers['User-Agent'] = if env.request_headers['User-Agent']
                                        @user_agent + " (#{env.request_headers['User-Agent']})"
                                      else
                                        @user_agent
                                      end
  @app.call(env)
end