Sha256: 2e417c8e83639356618401cbdca37491601aa97abae6ebec4d7de01154572748
Contents?: true
Size: 507 Bytes
Versions: 3
Compression:
Stored size: 507 Bytes
Contents
require 'faraday' module GCMMiddleware class Authentication < Faraday::Middleware def initialize(app, options = {}) super(app) @key = options.fetch(:key, '') raise ArgumentError.new('No api key was provided') if @key.nil? || @key.empty? end def call(env) env.request_headers['Authorization'] = auth_key @app.call(env).on_complete { |env| } end private attr_reader :key def auth_key @auth_key ||= "key=#{key}".freeze end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gcm_middleware-0.0.4 | lib/gcm_middleware/authentication.rb |
gcm_middleware-0.0.3 | lib/gcm_middleware/authentication.rb |
gcm_middleware-0.0.2 | lib/gcm_middleware/authentication.rb |