class Flon::Request

Represents a request.

Attributes

body[R]

@return [String] the body of the request

headers[R]

@return [Hash{String => String}] the headers of the request

method[R]

@return [Symbol] the request's method as a lowercase symbol

params[R]

@return [Hash{String => String}] the merged hash of {route_params} and

{query_params}. Route parameters take precedence
path[R]

@return [String] the request's path

query_params[R]

@return [Hash{Symbol => String}] the query parameters from the query

string
route_params[R]

@return [Hash{Symbol => String}] the route parameters

url[R]

@return [URI] the URL associated with this request

Public Class Methods

new(method, rack_request, route_params, body) click to toggle source

@api private

# File lib/flon/api.rb, line 37
def initialize(method, rack_request, route_params, body)
  @body = body
  @headers = rack_request.env
  @method = method
  @query_params = rack_request.params
  @route_params = route_params
  @params = coalesce_params(@query_params, @route_params)
  @path = rack_request.path_info
  @url = make_url(rack_request)
end

Private Instance Methods

coalesce_params(query_params, route_params) click to toggle source
# File lib/flon/api.rb, line 50
def coalesce_params(query_params, route_params)
  query_params.transform_keys(&:to_sym).merge(route_params)
end
make_url(request) click to toggle source
# File lib/flon/api.rb, line 54
def make_url(request)
  URI.parse(request.fullpath)
end