Class: Sbmt::Pact::Provider::MessageProviderServlet

Inherits:
WEBrick::HTTPServlet::ProcHandler
  • Object
show all
Defined in:
lib/sbmt/pact/provider/message_provider_servlet.rb

Constant Summary collapse

CONTENT_TYPE_JSON =
"application/json"
CONTENT_TYPE_PROTO =
"application/protobuf"
METADATA_HEADER =
"pact-message-metadata"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger: Logger.new($stdout)) ⇒ MessageProviderServlet

Returns a new instance of MessageProviderServlet.



15
16
17
18
19
20
21
# File 'lib/sbmt/pact/provider/message_provider_servlet.rb', line 15

def initialize(logger: Logger.new($stdout))
  super(build_proc)

  @message_handlers = {}

  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



9
10
11
# File 'lib/sbmt/pact/provider/message_provider_servlet.rb', line 9

def logger
  @logger
end

Instance Method Details

#add_message_handler(name, &block) ⇒ Object



23
24
25
26
27
# File 'lib/sbmt/pact/provider/message_provider_servlet.rb', line 23

def add_message_handler(name, &block)
  raise "message handler for #{name} already configured" if @message_handlers[name].present?

  @message_handlers[name] = {proc: block}
end