class Rasti::Web::ApiDoc::Request
Attributes
env[R]
Public Class Methods
new(env)
click to toggle source
# File lib/rasti/web/api_doc/request.rb, line 6 def initialize(env) @env = env end
Public Instance Methods
form_params()
click to toggle source
# File lib/rasti/web/api_doc/request.rb, line 34 def form_params env['rack.request.form_hash'] || {} end
headers()
click to toggle source
# File lib/rasti/web/api_doc/request.rb, line 38 def headers headers = env.select { |k,v| k.start_with?('HTTP_') || k == 'CONTENT_TYPE' } .map { |k,v| [k.sub(/^HTTP_/, '').split('_').map(&:capitalize).join('-'), v] } .sort Hash[headers] end
method()
click to toggle source
# File lib/rasti/web/api_doc/request.rb, line 10 def method env['REQUEST_METHOD'] end
path_info()
click to toggle source
# File lib/rasti/web/api_doc/request.rb, line 14 def path_info env['PATH_INFO'] end
query_params()
click to toggle source
# File lib/rasti/web/api_doc/request.rb, line 30 def query_params env['rack.request.query_hash'] || {} end
route()
click to toggle source
# File lib/rasti/web/api_doc/request.rb, line 18 def route env['PATH_INFO'].dup.tap do |path_info| route_params.each do |name, value| path_info.sub! value, ":#{name}" end end end
route_params()
click to toggle source
# File lib/rasti/web/api_doc/request.rb, line 26 def route_params env['rack.request.route_params'] || {} end