class ApiBlueprint::Collect::ControllerHook::Parser
Attributes
input[R]
Public Class Methods
new(input)
click to toggle source
# File lib/api_blueprint/collect/controller_hook.rb, line 11 def initialize(input) @input = input end
Public Instance Methods
body()
click to toggle source
# File lib/api_blueprint/collect/controller_hook.rb, line 33 def body if input.content_type == 'application/json' if input.body != 'null' JSON.parse(input.body) else "" end else input.body end end
headers()
click to toggle source
# File lib/api_blueprint/collect/controller_hook.rb, line 25 def headers Hash[input.headers.env.select do |k, v| (k.start_with?("HTTP_X_") || k == 'ACCEPT') && v end.map do |k, v| [human_header_key(k), v] end] end
method()
click to toggle source
# File lib/api_blueprint/collect/controller_hook.rb, line 15 def method input.method.to_s.upcase end
params()
click to toggle source
# File lib/api_blueprint/collect/controller_hook.rb, line 19 def params JSON.parse(input.params.reject do |k,_| ['action', 'controller'].include?(k) end.to_json) end
Private Instance Methods
human_header_key(key)
click to toggle source
# File lib/api_blueprint/collect/controller_hook.rb, line 47 def human_header_key(key) key.sub("HTTP_", '').split("_").map do |x| x.downcase end.join("_") end