Class: ElmerFudd::JsonFilter

Inherits:
Object
  • Object
show all
Extended by:
Filter
Defined in:
lib/ElmerFudd/json_filter.rb

Class Method Summary collapse

Methods included from Filter

call_next

Class Method Details

.call(env, message, filters) ⇒ Object



9
10
11
12
13
14
# File 'lib/ElmerFudd/json_filter.rb', line 9

def self.call(env, message, filters)
  message.payload = JSON.parse(message.payload)
  {result: call_next(env, message, filters)}.to_json
rescue JSON::ParserError
  env.logger.error "Ignoring invalid JSON: #{message.payload}"
end

.setup(handler) ⇒ Object



5
6
7
# File 'lib/ElmerFudd/json_filter.rb', line 5

def self.setup(handler)
  handler.call_reply_content_type = 'application/json'
end