Class: Yandex::Webmaster::Request::OAuth2

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/yandex-webmaster/request/oauth2.rb

Constant Summary collapse

AUTH_HEADER =
'Authorization'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, *args) ⇒ OAuth2

Returns a new instance of OAuth2.



20
21
22
23
24
# File 'lib/yandex-webmaster/request/oauth2.rb', line 20

def initialize(app, *args)
  super app
  @app = app
  @token = args.shift
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
# File 'lib/yandex-webmaster/request/oauth2.rb', line 14

def call(env)
  env[:request_headers].merge!(AUTH_HEADER => "OAuth #{@token}") if @token.present?

  @app.call env
end