Class: TravelTime::Middleware::ProtoMiddleware

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/travel_time/middleware/proto.rb

Overview

The Proto middleware is responsible for setting the basic auth headers for proto requests on each request. These are automatically taken from the ‘TravelTime.config`.

Instance Method Summary collapse

Instance Method Details

#on_request(env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/travel_time/middleware/proto.rb', line 11

def on_request(env)
  env.request_headers['Authorization'] =
    "Basic #{Base64.encode64("#{TravelTime.config.application_id}:#{TravelTime.config.api_key}")}"
  env.request_headers['Content-Type'] = 'application/octet-stream'
  env.request_headers['Accept'] = 'application/octet-stream'
  env.request_headers['User-Agent'] = 'Travel Time Ruby SDK'
end