Class: Flon::Request
- Inherits:
-
Object
- Object
- Flon::Request
- Defined in:
- lib/flon/api.rb
Overview
Represents a request.
Instance Attribute Summary collapse
-
#body ⇒ String
readonly
The body of the request.
-
#headers ⇒ Hash{String => String}
readonly
The headers of the request.
-
#method ⇒ Symbol
readonly
The request’s method as a lowercase symbol.
-
#params ⇒ Hash{String => String}
readonly
The merged hash of #route_params and #query_params.
-
#path ⇒ String
readonly
The request’s path.
-
#query_params ⇒ Hash{Symbol => String}
readonly
The query parameters from the query string.
-
#route_params ⇒ Hash{Symbol => String}
readonly
The route parameters.
-
#url ⇒ URI
readonly
The URL associated with this request.
Instance Method Summary collapse
-
#initialize(method, rack_request, route_params, body) ⇒ Request
constructor
private
A new instance of Request.
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
#body ⇒ String (readonly)
Returns the body of the request.
11 12 13 |
# File 'lib/flon/api.rb', line 11 def body @body end |
#headers ⇒ Hash{String => String} (readonly)
Returns the headers of the request.
14 15 16 |
# File 'lib/flon/api.rb', line 14 def headers @headers end |
#method ⇒ Symbol (readonly)
Returns the request’s method as a lowercase symbol.
17 18 19 |
# File 'lib/flon/api.rb', line 17 def method @method end |
#params ⇒ Hash{String => String} (readonly)
Returns the merged hash of #route_params and #query_params. Route parameters take precedence.
21 22 23 |
# File 'lib/flon/api.rb', line 21 def params @params end |
#path ⇒ String (readonly)
Returns the request’s path.
24 25 26 |
# File 'lib/flon/api.rb', line 24 def path @path end |
#query_params ⇒ Hash{Symbol => String} (readonly)
Returns the query parameters from the query string.
28 29 30 |
# File 'lib/flon/api.rb', line 28 def query_params @query_params end |
#route_params ⇒ Hash{Symbol => String} (readonly)
Returns the route parameters.
31 32 33 |
# File 'lib/flon/api.rb', line 31 def route_params @route_params end |
#url ⇒ URI (readonly)
Returns the URL associated with this request.
34 35 36 |
# File 'lib/flon/api.rb', line 34 def url @url end |