Mix.Statifier.BasicHTTPFront (Statifier v2.10.0)

Copy Markdown View Source

The loopback inbound front this repository's own runs deliver Basic HTTP sends through (ADR-0075), on OTP's :inets httpd, with no dependency. It is repository tooling, not part of the package.

start/0 binds a free port on 127.0.0.1 and answers the base URL a Statifier.Send.BasicHTTP registration takes as its :base_url, so a session's _ioprocessors location is base_url <> "/" <> session_id. A request to that location is resolved to the live session registered under the id in Statifier.Registry, decoded by Statifier.Send.BasicHTTP.decode/1, and enqueued on the session as an external event, with the request's scxml-send-key header handed to the decoder. This front does not deduplicate on that header (ADR-0075's Amendment of 2026-09-30 leaves that to a front that outlives a restart). The status rule is the decoder's (ADR-0075 decision 5):

  • 204 once the event is enqueued, before it is processed;
  • 405 with Allow: POST for any other method;
  • 400 for a request that forms no event;
  • 404 for a path that names no live session.

Summary

Types

t()

A running front: the httpd process and the base URL it answers at.

Functions

The httpd callback, do/1 (a name only unquote/1 can define): answers one request by the status rule in the moduledoc, through respond/1.

Answers one httpd request by the status rule in the moduledoc.

Starts a front on a free loopback port. Starts :inets first.

Stops a front start/0 started.

Types

t()

@type t() :: %{pid: pid(), base_url: String.t()}

A running front: the httpd process and the base URL it answers at.

Functions

do(mod_data)

@spec do(mod_data :: tuple()) :: {:proceed, list()}

The httpd callback, do/1 (a name only unquote/1 can define): answers one request by the status rule in the moduledoc, through respond/1.

respond(mod_data)

@spec respond(mod_data :: tuple()) :: {:proceed, list()}

Answers one httpd request by the status rule in the moduledoc.

start()

@spec start() :: {:ok, t()} | {:error, term()}

Starts a front on a free loopback port. Starts :inets first.

stop(map)

@spec stop(front :: t()) :: :ok | {:error, term()}

Stops a front start/0 started.