Sha256: 0d58c8c8f25d9eefdaa4b33fd9a431627731a12401266662b2bb32c94848268e

Contents?: true

Size: 420 Bytes

Versions: 2

Compression:

Stored size: 420 Bytes

Contents

require 'faraday'

module Evrythng
  module Request
    class TokenAuthentication < Faraday::Middleware

      def initialize(app, token, options={})
        super(app)

        @header_value = token
      end

      def call(env)
        unless env[:request_headers]['X-Evrythng-Token']
          env[:request_headers]['X-Evrythng-Token'] = @header_value
        end
        @app.call(env)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
evrythng-0.1.1 lib/evrythng/request/token_authentication.rb
evrythng-0.1.0 lib/evrythng/request/token_authentication.rb