# `AshHooks.Transport`
[🔗](https://github.com/baselabs/ash_hooks/blob/v3.3.0/lib/ash_hooks/transport.ex#L1)

Use another transport for an endpoint while retaining signing, retry handling,
attempt history, and telemetry. A transport implements the same `request/5`
contract as an HTTP adapter.

<!-- not-run: This transport requires the host forwarding protocol implementation. -->

    defmodule MyApp.CliForwarderTransport do
      @behaviour AshHooks.Transport

      @impl true
      def request(_method, url, headers, body, _opts) do
        # push the signed request to the developer's laptop over your
        # forwarder protocol; answer with the forwarder's HTTP verdict
        MyApp.CliForwarder.send!(url, headers, body)
      end
    end

Route per endpoint through the worker option (or direct-run config)
`transport: {module, function}` / a 2-arity fn receiving the endpoint
record and tenant, returning the transport module (or `nil` to keep the
HTTP adapter). A transport module must export `request/5`. A resolver
that raises, throws, exits, or returns an invalid value refuses the
attempt as a retryable `transport_resolution` failure, and so does a
`transport` setting that is neither shape. It does not fall back to HTTP. No exception contents or returned terms are stored
or emitted; only the fixed classification is retained.

The callback contract is `AshHooks.Http`'s adapter contract verbatim:
one `request/5` returning `{:ok, %{status, headers, body}}` or
`{:error, reason}`; the runtime's classification table (2xx succeeds,
408/429/5xx retry honoring Retry-After, 410 conditionally disables the
endpoint and dead-letters the delivery, other 4xx dead-letter, redirects
refused, transport errors retry) applies unchanged. A destination
policy allowing the forwarder's URL scheme keeps the send-time gate
open for it (see `AshHooks.DestinationPolicy`).

# `request`

```elixir
@callback request(atom(), String.t(), map(), binary(), keyword()) ::
  {:ok, %{status: integer(), headers: list(), body: binary() | nil}}
  | {:error, term()}
```

# `send_prepared`
*optional* 

```elixir
@callback send_prepared(AshHooks.Http.Request.t(), keyword()) ::
  {:ok, %{status: integer(), headers: list(), body: binary() | nil}}
  | {:error, term()}
```

Sends the prepared method, target, ordered header lines and body unchanged.
Write `method target HTTP/1.1`, then exactly the supplied lines in order,
then the body. Add, remove, duplicate or reorder nothing. Custom adapters
and transports own this trusted boundary, including any downstream hop.

---

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