Class: GreenGoose::Middleware::JSON
- Inherits:
-
Faraday::Request::UrlEncoded
- Object
- Faraday::Request::UrlEncoded
- GreenGoose::Middleware::JSON
- Defined in:
- lib/greengoose/middleware/json.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/greengoose/middleware/json.rb', line 8 def call(env) match_content_type(env) do |data| env[:body] = ::MultiJson.dump(data) end @app.call(env).on_complete do env[:body] = parse(env[:body]) end end |
#parse(body) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/greengoose/middleware/json.rb', line 18 def parse(body) case body when '' nil when 'true' true when 'false' false else ::MultiJson.load(body) end end |