class Simpal::Middleware::Headers
Allows the use of convenience header names which are then mapped into the real header name.
Constants
- PAYPAL_HEADERS
@return [Array] The request headers which must have the 'PayPal-' prefix applied to them.
Public Instance Methods
on_request(env)
click to toggle source
# File lib/simpal/middleware/headers.rb, line 17 def on_request(env) headers = env[:request_headers] return unless headers.is_a?(Hash) # Prefer full representations, instead of the minimal response by default. headers['Prefer'] = 'return=representation' unless headers.key?('Prefer') PAYPAL_HEADERS.each do |header| headers["PayPal-#{header}"] = headers.delete(header) if headers.key?(header) end env[:request_headers] = headers end