Raxx

Interface for HTTP webservers and frameworks. Supports server, client and bidirectional streaming.

Hello World!

Hello world example where the client sends a single request to the server and gets a single response back.

defmodule MyApp.WW do
  use Raxx.Server

  @impl Raxx.Server
  def handle_request(_request, _config) do
    Raxx.response(:ok)
    |> Raxx.set_header("content-type", "text/plain")
    |> Raxx.set_body("Hello, World!")
  end
end

Echo server example where the request body is streamed back to the client as it becomes available.

defmodule MyApp.Echo do
  use Raxx.Server

  @impl Raxx.Server
  def handle_headers(_request, state) do
    outbound = Raxx.response(:ok)
    |> Raxx.set_body(true)

    {[outbound], state}
  end

  @impl Raxx.Server
  def handle_fragment(data, state) do
    outbound = Raxx.fragment(data)

    {[outbound], state}
  end

  @impl Raxx.Server
  def handle_trailers(_trailers, state) do
    outbound = Raxx.trailer()

    {[outbound], state}
  end
end

Raxx.Server specifies 5 callbacks allowing implementers to handle:

  • Unary request/response exchanges.
  • Client streamed requests.
  • Server streamed responses.
  • Bidirectional streaming.

See documentation on hexdocs for details.

Community

Testing

To work with Raxx locally Elixir 1.4 or greater must be installed.

git clone git@github.com:CrowdHailer/raxx.git
cd raxx

mix deps.get
mix test