# `Mix.Statifier.BasicHTTPFront`
[🔗](https://github.com/riddler/statifier-ex/blob/v2.10.0/lib/mix/statifier/basic_http_front.ex#L1)

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.

# `t`

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

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

# `do`

```elixir
@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`

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

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

# `start`

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

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

# `stop`

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

Stops a front `start/0` started.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
