Class: GCMMiddleware::Authentication
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- GCMMiddleware::Authentication
- Defined in:
- lib/gcm_middleware/authentication.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Authentication
constructor
A new instance of Authentication.
Constructor Details
#initialize(app, options = {}) ⇒ Authentication
Returns a new instance of Authentication.
5 6 7 8 9 10 |
# File 'lib/gcm_middleware/authentication.rb', line 5 def initialize(app, = {}) super(app) @key = .fetch(:key, '') raise ArgumentError.new('No api key was provided') if @key.nil? || @key.empty? end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 |
# File 'lib/gcm_middleware/authentication.rb', line 12 def call(env) env.request_headers['Authorization'] = auth_key @app.call(env).on_complete { |env| } end |