Packages

Elixir client for the Routemaster event bus server. Supports publishing events, subscribing to topics, receiving and processing events. Also incluses a HTTP client integrated with a builtin cache service.

Current section

Files

Jump to
routemaster_client lib routemaster drain plugs parser.ex
Raw

lib/routemaster/drain/plugs/parser.ex

defmodule Routemaster.Plugs.Parser do
@moduledoc """
Parses the request bodies of incoming event delivery requests
to extract the event list payloads.
Uses `Routemaster.Drain.JsonDecoder`.
"""
use Plug.Builder
plug Plug.Parsers, parsers: [:json], json_decoder: Routemaster.Drain.JsonDecoder
# When decoding JSON with root-level arrays, Poison will merge in the params
# with a "_json" key. Here we extract them and move them in the assigns.
#
def call(conn, opts) do
conn = super(conn, opts)
assign(conn, :events, conn.params["_json"])
end
end