Class: LogStash::Filters::RequestBodiesParsed

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/filters/request_bodies_parsed.rb

Instance Method Summary collapse

Instance Method Details

#filter(event) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/logstash/filters/request_bodies_parsed.rb', line 17

def filter(event)
  %w(request response).each do |re|
    if event[re].is_a?(Hash) && event[re]['body'].is_a?(String)
      _, content_type = event[re].detect { |(k,_)| k =~ /\Acontent.type\z/i }
      if event[re]['headers'].is_a?(Hash) && !content_type
        _, content_type = event[re]['headers'].detect { |(k,_)| k =~ /\Acontent.type\z/i }
      end
      parsed_body = ApiHammer::Body.new(event[re]['body'], content_type)
      event[re]['body_parsed'] = parsed_body.object if parsed_body.object
    end
  end
end

#registerObject



13
14
# File 'lib/logstash/filters/request_bodies_parsed.rb', line 13

def register
end