Class: Cobinhood::AuthRequestMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Cobinhood::AuthRequestMiddleware
- Defined in:
- lib/cobinhood/client/rest/auth_request_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, api_key) ⇒ AuthRequestMiddleware
constructor
A new instance of AuthRequestMiddleware.
Constructor Details
#initialize(app, api_key) ⇒ AuthRequestMiddleware
Returns a new instance of AuthRequestMiddleware.
4 5 6 7 |
# File 'lib/cobinhood/client/rest/auth_request_middleware.rb', line 4 def initialize app, api_key super(app) @api_key = api_key.to_s end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 |
# File 'lib/cobinhood/client/rest/auth_request_middleware.rb', line 9 def call env raise Cobinhood::MissingApiKeyError.new('API KEY not provided') if @api_key.empty? env[:request_headers]["authorization"] = @api_key @app.call(env) end |