Class: Webmaster::Request::OAuth2

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/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.



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

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

Instance Method Details

#call(env) ⇒ Object



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

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

  @app.call env
end