Skip to main content

Crate alux_http_direct

Crate alux_http_direct 

Source
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§

DirectBodyInput
Marks a JSON value read from the request body.
DirectBytesOutput
Renders a semantic result as a raw-byte answer.
DirectCookieInput
Marks a value read from the cookies a caller sent.
DirectEmptyOutput
Renders a handler that returns nothing as an answer with no body.
DirectEndpoint
Erases what one endpoint does with a request it was reached by.
DirectError
What the interpretation itself answers when no handler can be reached.
DirectFileOutput
Renders a semantic file result as a downloadable answer.
DirectFormInput
Marks a form-encoded value read from the request body.
DirectHandlerImpl
Interprets typed HTTP programs as a surface that answers requests itself.
DirectHeadInput
Marks a value read from the request head.
DirectHeaderInput
Marks a value read from the headers a caller sent.
DirectHeaderOutput
Answers with a header the handler stated, beside the body it stated.
DirectHtmlOutput
Renders a semantic result as an HTML answer.
DirectJsonOutput
Renders a semantic result as a JSON answer.
DirectMultipartInput
Marks an argument read from a body arriving as parts.
DirectPathInput
Marks a value read from the segments a path bound.
DirectQueryInput
Marks a value read from the query string.
DirectRawBodyInput
Marks the request body taken as it arrived.
DirectRedirectOutput
Renders a semantic location as a redirect.
DirectRequest
What a caller sent, stated without a transport.
DirectResponse
What a surface answered, stated without a transport.
DirectResultOutput
Answers with what a failure means when the handler failed, and with the body it states otherwise.
DirectRoute
Carries a composable collection of endpoints and the selectors that reach them.
DirectRouteImpl
Interprets categorical route composition as the only routing this interpretation needs.
DirectSelector
Carries route-selection meaning, which for this interpretation is all the routing there is.
DirectStatusOutput
Answers with the status an endpoint declared, around the body it already states.
DirectStreamOutput
Answers with a body produced over time.
DirectTextOutput
Renders a semantic result as a plain-text answer.

Enums§

DirectBody
What an answer carries, which is either bytes already in hand or bytes still to come.

Traits§

FromBodyAlg
Reads the handler argument a request body states, taken as it arrived.
FromCapturesAlg
Reads the handler argument a path’s captured segments state.
FromHeadAlg
Reads the handler argument a request head states.

Type Aliases§

Answer
The answer one reached endpoint produces.
Chunks
What produces a body over time, once an interpretation has chosen how to carry it.