Class: ClickHouse::Middleware::ParseJson

Inherits:
ResponseBase
  • Object
show all
Defined in:
lib/click_house/middleware/parse_json.rb

Constant Summary

Constants inherited from ResponseBase

ResponseBase::CONTENT_TYPE_HEADER

Instance Attribute Summary

Attributes inherited from ResponseBase

#content_type, #options

Instance Method Summary collapse

Methods inherited from ResponseBase

#config, #content_type?, #initialize

Constructor Details

This class inherits a constructor from ClickHouse::Middleware::ResponseBase

Instance Method Details

#on_complete(env) ⇒ Object

Parameters:

  • env (Faraday::Env)


9
10
11
12
13
# File 'lib/click_house/middleware/parse_json.rb', line 9

def on_complete(env)
  return unless content_type?(env, content_type)

  env.body = JSON.parse(env.body, config.json_load_options) unless env.body.strip.empty?
end