Class: FaradayMiddleware::Inthegra

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/faraday/inthegra.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, auth_token = nil) ⇒ Inthegra

Returns a new instance of Inthegra.



12
13
14
15
# File 'lib/faraday/inthegra.rb', line 12

def initialize(app, auth_token = nil)
  @app = app
  @auth_token = auth_token
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  if @auth_token
    env[:request_headers] = env[:request_headers].merge('X-Auth-Token' => @auth_token.token)
  end

  @app.call env
end