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