Class: Flatrack::Request
- Inherits:
-
Object
- Object
- Flatrack::Request
- Defined in:
- lib/flatrack/request.rb
Constant Summary collapse
- DEFAULT_FORMAT =
'html'
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
-
#initialize(env) ⇒ Request
constructor
A new instance of Request.
- #params ⇒ Object
- #path ⇒ Object
- #response ⇒ Object
Constructor Details
#initialize(env) ⇒ Request
Returns a new instance of Request.
7 8 9 10 |
# File 'lib/flatrack/request.rb', line 7 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
20 21 22 |
# File 'lib/flatrack/request.rb', line 20 def format (ext = File.extname path).empty? ? DEFAULT_FORMAT : ext.sub(/\./, '') end |
#params ⇒ Object
16 17 18 |
# File 'lib/flatrack/request.rb', line 16 def params rack_request.params.with_indifferent_access end |
#path ⇒ Object
12 13 14 |
# File 'lib/flatrack/request.rb', line 12 def path env['PATH_INFO'] end |
#response ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/flatrack/request.rb', line 24 def response Response.new(self).render rescue TemplateNotFound respond_with_error(500) rescue FileNotFound respond_with_error(404) end |