Class: Flon::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/flon/api.rb

Overview

Represents a request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, rack_request, route_params, body) ⇒ Request

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Request.



37
38
39
40
41
42
43
44
45
46
# 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

Instance Attribute Details

#bodyString (readonly)

Returns the body of the request.

Returns:

  • (String)

    the body of the request



11
12
13
# File 'lib/flon/api.rb', line 11

def body
  @body
end

#headersHash{String => String} (readonly)

Returns the headers of the request.

Returns:

  • (Hash{String => String})

    the headers of the request



14
15
16
# File 'lib/flon/api.rb', line 14

def headers
  @headers
end

#methodSymbol (readonly)

Returns the request’s method as a lowercase symbol.

Returns:

  • (Symbol)

    the request’s method as a lowercase symbol



17
18
19
# File 'lib/flon/api.rb', line 17

def method
  @method
end

#paramsHash{String => String} (readonly)

Returns the merged hash of #route_params and #query_params. Route parameters take precedence.

Returns:



21
22
23
# File 'lib/flon/api.rb', line 21

def params
  @params
end

#pathString (readonly)

Returns the request’s path.

Returns:

  • (String)

    the request’s path



24
25
26
# File 'lib/flon/api.rb', line 24

def path
  @path
end

#query_paramsHash{Symbol => String} (readonly)

Returns the query parameters from the query string.

Returns:

  • (Hash{Symbol => String})

    the query parameters from the query string



28
29
30
# File 'lib/flon/api.rb', line 28

def query_params
  @query_params
end

#route_paramsHash{Symbol => String} (readonly)

Returns the route parameters.

Returns:

  • (Hash{Symbol => String})

    the route parameters



31
32
33
# File 'lib/flon/api.rb', line 31

def route_params
  @route_params
end

#urlURI (readonly)

Returns the URL associated with this request.

Returns:

  • (URI)

    the URL associated with this request



34
35
36
# File 'lib/flon/api.rb', line 34

def url
  @url
end