Skip to main content

Module request

Module request 

Source
Expand description

HTTP-shaped per-request work and the in-pipeline Context service contract.

Two request types coexist here, intentionally:

  • YetiRequest / YetiResponse — the protocol-edge shape (http::Request<Bytes> / http::Response<Bytes>). Every transport (HTTP, MQTT, MCP) translates its inbound payload into this, runs edge-level Services (e.g. tower-http CORS / compression / tracing), and translates the response back. Plugins targeting raw HTTP edge concerns implement Service<YetiRequest>.

  • ContextService — the internal pipeline shape. Once the router has resolved app/resource/path-id and constructed a Context, every downstream layer (auth resolution, rate limiting, table dispatch) is a Service<Context, Response = Context, Error = YetiError>.

Context is Clone: every field is Bytes / Arc<str> / Arc<dyn Trait> / small map, so cloning is cheap. With Clone, Context flows through tower::Service<YetiRequest> chains via http::Request::extensions (the standard tower-http pattern).

Structs§

RequestPipeline
Sequential runner for a chain of ContextServices. The pipeline owns the services and threads a Context through them one after another, short-circuiting on the first error.

Functions§

compose
Compose a slice of ContextServices into a single ContextService that runs them in registration order. The composed service is BoxCloneSyncService, so cloning it is one Arc bump regardless of chain length. Each underlying service still requires a per-call clone (to satisfy &mut self), but the outer container is shared — so the per-request work scales with chain length only inside the Future, not at the boundary.

Type Aliases§

ContextService
The middleware-pipeline service type. Each registered service consumes a Context and returns a (possibly mutated) Context, or fails with YetiError.
YetiRequest
The canonical Yeti request — http::Request<Bytes> — for protocol-edge services. The router peels this apart into a Context before invoking the middleware pipeline.
YetiResponse
The canonical Yeti response — http::Response<Bytes>.