Module: Hobby::JSON
- Defined in:
- lib/hobby/json.rb
Defined Under Namespace
Classes: Response
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(app) ⇒ Object
6 7 8 9 |
# File 'lib/hobby/json.rb', line 6 def self.included app app.use Rack::ContentType, 'application/json' app.response = Response end |
Instance Method Details
#json ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/hobby/json.rb', line 17 def json @json ||= begin ::JSON.parse request.body.read rescue response.status = 400 throw :halt, response end end |