class Routemaster::Drain::Terminator

Tiny Rack app to terminates a Routemaster middleware chain.

Respond 204 if a payload has been parsed (i.e. present in the environment) and 400 if not.

If an event payload has been placed in ‘env` by upper middleware, broadcasts the `:events_received` event with the payload.

Nothing will be broadcast if the payload is empty.

Public Instance Methods

call(env) click to toggle source
# File lib/routemaster/drain/terminator.rb, line 19
def call(env)
  payload = env['routemaster.payload']
  if payload.nil?
    return [400, {'Content-Type' => 'text/plain'}, 'no payload parsed']
  end

  publish(:events_received, payload) if payload.any?
  [204, {}, []]
end