Class: Rack::OauthProxy::Client::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/oauth_proxy/client/request.rb

Constant Summary collapse

DEFAULT_PROPAGATED_HEADER_FIELDS =
["Authorization"]
DEFAULT_PROPAGATED_PARAMS =
["access_token", "bearer_token"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, options = {}) ⇒ Request

Returns a new instance of Request.



15
16
17
18
# File 'lib/rack/oauth_proxy/client/request.rb', line 15

def initialize(env, options = {})
  @env = env
  @options = options
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



13
14
15
# File 'lib/rack/oauth_proxy/client/request.rb', line 13

def env
  @env
end

#optionsObject (readonly)

Returns the value of attribute options.



13
14
15
# File 'lib/rack/oauth_proxy/client/request.rb', line 13

def options
  @options
end

Instance Method Details

#headerObject



20
21
22
# File 'lib/rack/oauth_proxy/client/request.rb', line 20

def header
  header_with_nil_value.reject {|key, value| value.nil? }
end

#header_with_nil_valueObject



24
25
26
27
28
# File 'lib/rack/oauth_proxy/client/request.rb', line 24

def header_with_nil_value
  propagated_header_fields.inject({}) do |result, field|
    result.merge(field => env["HTTP_" + field.gsub("-", "_").upcase])
  end
end

#paramsObject



30
31
32
# File 'lib/rack/oauth_proxy/client/request.rb', line 30

def params
  rack_request.params.slice(*propagated_params)
end