Class: Rasti::Web::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Rasti::Web::Request
- Defined in:
- lib/rasti/web/request.rb
Instance Method Summary collapse
Instance Method Details
#body_text ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/rasti/web/request.rb', line 14 def body_text @body_text ||= begin text = body.read body.rewind text end end |
#json? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/rasti/web/request.rb', line 22 def json? !content_type.nil? && ContentType.parse(content_type).mime_type == 'application/json' rescue false end |
#params ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/rasti/web/request.rb', line 5 def params @params ||= Hash::Indifferent.new.tap do |hash| hash.update self.GET hash.update self.POST hash.update env[ROUTE_PARAMS] if env.key? ROUTE_PARAMS hash.update JSON.parse(body_text) if json? && body_text end end |