Class: Flatrack::Request
- Inherits:
-
Object
- Object
- Flatrack::Request
- Defined in:
- lib/flatrack/request.rb
Overview
parses an incoming flatrack request and provides a method to render a response
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#rack_request ⇒ Object
readonly
Returns the value of attribute rack_request.
Instance Method Summary collapse
-
#format ⇒ Object
the format on the incoming request.
-
#initialize(env) ⇒ Request
constructor
Initializes a response.
-
#params ⇒ Object
the params on the incoming request.
-
#path ⇒ Object
the path of the incoming request.
-
#response ⇒ Object
the processed response for an inbound request.
Constructor Details
#initialize(env) ⇒ Request
Initializes a response
9 10 11 12 |
# File 'lib/flatrack/request.rb', line 9 def initialize(env) @rack_request = Rack::Request.new(env) @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/flatrack/request.rb', line 5 def env @env end |
#rack_request ⇒ Object (readonly)
Returns the value of attribute rack_request.
5 6 7 |
# File 'lib/flatrack/request.rb', line 5 def rack_request @rack_request end |
Instance Method Details
#format ⇒ Object
the format on the incoming request
25 26 27 28 29 30 31 |
# File 'lib/flatrack/request.rb', line 25 def format ext = File.extname path unless ext.empty? path.sub!(/#{ext}/, '') ext.split('.').last end end |
#params ⇒ Object
the params on the incoming request
20 21 22 |
# File 'lib/flatrack/request.rb', line 20 def params rack_request.params.with_indifferent_access end |
#path ⇒ Object
the path of the incoming request
15 16 17 |
# File 'lib/flatrack/request.rb', line 15 def path env['PATH_INFO'] end |
#response ⇒ Object
the processed response for an inbound request
34 35 36 37 38 39 40 |
# File 'lib/flatrack/request.rb', line 34 def response Response.new(self).render rescue TemplateNotFound respond_with_error(500) rescue FileNotFound respond_with_error(404) end |