Expand description
§alux-http-direct
alux-http-direct interprets an alux-http program as a surface that
answers requests itself, with no framework.
This interpreter performs the specification directly: it matches a request against the paths in the program, binds captured values, reads each argument from its declared role, applies the operation, and renders the answer, including routing failures. It carries no transport or runtime, so the caller decides how requests arrive and responses leave.
use alux_http::{HttpMethod, HttpProgramExt};
use alux_http_direct::{DirectHandlerImpl, DirectRequest};
let api = DirectHandlerImpl::new(App::new());
let surface = api.compile_http(api.status_api::<App>());
let answer = surface.answer(DirectRequest::new(HttpMethod::Get, "/status")).await;
assert_eq!(answer.text(), "1");Because it answers with values rather than with a framework’s types, it is the reference another
interpretation can be held to: alux-http-poem and
alux-http-axum fold the same program and must reach the same
endpoint for the same request.
Routing here needs no path spelling at all. The program already states a path as segments, so a literal matches itself, a parameter binds one segment, and a tail binds the rest, and nothing is ever rendered for a router to parse back.
Interprets typed HTTP programs as a surface that answers requests itself.
This interpretation implements the specification rather than delegating to a framework: it matches a request against the paths a program states, binds what those paths capture, reads each argument from the role it was declared under, applies the operation, and renders the answer, including the failures routing itself produces. It carries no transport and no runtime, so whatever moves bytes decides how a request arrives.
Because it answers with values rather than with a framework’s types, it is the reference another interpretation can be held to.
Structs§
- Direct
Body Input - Marks a JSON value read from the request body.
- Direct
Bytes Output - Renders a semantic result as a raw-byte answer.
- Direct
Cookie Input - Marks a value read from the cookies a caller sent.
- Direct
Empty Output - Renders a handler that returns nothing as an answer with no body.
- Direct
Endpoint - Erases what one endpoint does with a request it was reached by.
- Direct
Error - What the interpretation itself answers when no handler can be reached.
- Direct
File Output - Renders a semantic file result as a downloadable answer.
- Direct
Form Input - Marks a form-encoded value read from the request body.
- Direct
Handler Impl - Interprets typed HTTP programs as a surface that answers requests itself.
- Direct
Head Input - Marks a value read from the request head.
- Direct
Header Input - Marks a value read from the headers a caller sent.
- Direct
Header Output - Answers with a header the handler stated, beside the body it stated.
- Direct
Html Output - Renders a semantic result as an HTML answer.
- Direct
Json Output - Renders a semantic result as a JSON answer.
- Direct
Multipart Input - Marks an argument read from a body arriving as parts.
- Direct
Path Input - Marks a value read from the segments a path bound.
- Direct
Query Input - Marks a value read from the query string.
- Direct
RawBody Input - Marks the request body taken as it arrived.
- Direct
Redirect Output - Renders a semantic location as a redirect.
- Direct
Request - What a caller sent, stated without a transport.
- Direct
Response - What a surface answered, stated without a transport.
- Direct
Result Output - Answers with what a failure means when the handler failed, and with the body it states otherwise.
- Direct
Route - Carries a composable collection of endpoints and the selectors that reach them.
- Direct
Route Impl - Interprets categorical route composition as the only routing this interpretation needs.
- Direct
Selector - Carries route-selection meaning, which for this interpretation is all the routing there is.
- Direct
Status Output - Answers with the status an endpoint declared, around the body it already states.
- Direct
Stream Output - Answers with a body produced over time.
- Direct
Text Output - Renders a semantic result as a plain-text answer.
Enums§
- Direct
Body - What an answer carries, which is either bytes already in hand or bytes still to come.
Traits§
- From
Body Alg - Reads the handler argument a request body states, taken as it arrived.
- From
Captures Alg - Reads the handler argument a path’s captured segments state.
- From
Head Alg - Reads the handler argument a request head states.