Expand description
§alux-http-warp
alux-http-warp interprets an alux-http program as an executable
warp filter.
use alux_http::HttpProgramExt;
use alux_http_warp::WarpHandlerImpl;
let api = WarpHandlerImpl::new(App::new());
let filter = api.compile_http(api.status_api::<App>()).into_warp();
warp::serve(filter).run(([0, 0, 0, 0], 3000)).await;warp holds no route table: it composes filters, so a coproduct of routes is or and a selector is
the filters a request has to pass. A path is built from the segments the program states, with
warp::path for a literal, warp::path::param for a binding, and warp::path::tail for the rest,
so warp does the matching and the binding. What reaches an endpoint is what those filters gathered,
which is why the roles here read a gathered request rather than a framework extractor.
§A body produced over time
warp streams response bodies. It does not expose a way to build one.
warp::reply::Response is http::Response<BodyT>, and BodyT lives in warp’s private mod bodyt.
Its two constructors that take a stream are pub(crate):
// warp 0.4.3, src/bodyt.rs
pub(crate) fn wrap<B>(body: B) -> Self
where B: http_body::Body + Send + Sync + 'static;
pub(crate) fn wrap_stream<S, B, E>(stream: S) -> Self
where S: Stream<Item = Result<B, E>> + Send + Sync + 'static, B: Into<Bytes>;The public routes to a Response all take bytes already in hand: From<Bytes>, From<String>,
From<Vec<u8>>, From<&'static str>, From<&'static [u8]>, From<Option<Bytes>>. Implementing
warp::Reply does not help, because into_response must answer with the same Response.
So this crate does not implement StreamOutAlg, and .stream() fails to compile here while it
compiles for every other interpreter. The alternative is to collect the body first, which would make
this interpretation answer differently from the others for the same program.
warp::sse::reply does build a streaming body, but frames it as server-sent events: data: lines
and blank-line terminators. That is a different response body from the bytes .stream() states.
warp 0.3 re-exported hyper 0.14’s Body, which was publicly constructible from a stream. warp 0.4
moved to hyper 1 and http-body 1, defined BodyT over
BoxBody, and
kept it private.
wrap_stream, the constructorwarp::reply::Responsewarp::ReplyInterprets typed HTTP programs as an executable warp filter.
warp composes filters rather than holding a route table, so a coproduct of routes is or and a
selector is the filters a request must pass. What reaches an endpoint is what those filters
gathered, which is why the roles here read a gathered request rather than a framework extractor.
Structs§
- Warp
Body Input - Marks a JSON value read from the request body.
- Warp
Bytes Output - Renders a semantic result as a raw-byte reply.
- Warp
Cookie Input - Marks a value read from the cookies a caller sent.
- Warp
Empty Output - Renders a handler that returns nothing as a reply with no body.
- Warp
Endpoint - Erases what one endpoint does with a request warp’s filters matched.
- Warp
Error - States that an argument could not be read from where its role says it comes from.
- Warp
File Output - Renders a semantic file result as a downloadable reply.
- Warp
Form Input - Marks a form-encoded value read from the request body.
- Warp
Handler Impl - Interprets typed HTTP programs as an executable warp filter.
- Warp
Head Input - Marks a value read from the headers the caller sent.
- Warp
Header Input - Marks a value read from the headers a caller sent.
- Warp
Header Output - Answers with a header the handler stated, beside the body it stated.
- Warp
Html Output - Renders a semantic result as an HTML reply.
- Warp
Json Output - Renders a semantic result as a JSON reply.
- Warp
Multipart Input - Marks an argument read from a body arriving as parts.
- Warp
Path Input - Marks a value read from the segments a path bound.
- Warp
Query Input - Marks a value read from the query string.
- Warp
RawBody Input - Marks the request body taken as it arrived.
- Warp
Redirect Output - Renders a semantic location as a redirect.
- Warp
Request - What one matched request states, as warp’s filters gathered it.
- Warp
Result Output - Answers with what a failure means when the handler failed, and with the body it states otherwise.
- Warp
Route - Carries a composable collection of warp endpoints.
- Warp
Route Impl - Interprets categorical route composition as native warp filter composition.
- Warp
Selector - Carries route-selection meaning before it becomes the filters warp matches with.
- Warp
Server - Serves a warp route at the address its setup names.
- Warp
Status Output - Answers with the status an endpoint declared, around the body it already states.
- Warp
Text Output - Renders a semantic result as a plain-text reply.
Traits§
- From
Captured Alg - Reads the handler argument a path’s captured segments state.
- From
Headers Alg - Reads the handler argument the headers state.
- From
RawAlg - Reads the handler argument a request body states, taken as it arrived.
Functions§
- warp_
status - Interprets a portable status as the one warp answers with.
Type Aliases§
- Answer
- The answer one reached endpoint produces.