Class: BB::Middleware::Response::BBParser
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- BB::Middleware::Response::BBParser
- Defined in:
- lib/bb/middleware/response/bb_parser.rb
Overview
Middleware class responsible for customizing MHV BB response parsing
Instance Method Summary collapse
-
#on_complete(env) ⇒ Faraday::Env
Override the Faraday #on_complete method to filter body through custom #parse.
Instance Method Details
#on_complete(env) ⇒ Faraday::Env
Override the Faraday #on_complete method to filter body through custom #parse
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bb/middleware/response/bb_parser.rb', line 15 def on_complete(env) return unless env.response_headers['content-type']&.match?(/\bjson/) # If POST is successful message body is irrelevant # if it was not successul an exception would have already been raised return if env.method == :post # Don't parse the VHIE sharing status calls. return if env.url.to_s.include? 'optinout' env[:body] = parse(env.body) if env.body.present? end |