Class: Cpro::Middleware::ParseJson

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/cpro/middleware/json.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, content_type: /\bjson$/) ⇒ ParseJson

Returns a new instance of ParseJson.



26
27
28
29
# File 'lib/cpro/middleware/json.rb', line 26

def initialize(app, content_type: /\bjson$/)
  super(app)
  @content_type = content_type
end

Instance Method Details

#call(env) ⇒ Object



31
32
33
# File 'lib/cpro/middleware/json.rb', line 31

def call(env)
  @app.call(env).on_complete { |response| response.body = parse(response) }
end