Expand description
§alux-http-salvo
alux-http-salvo interprets an alux-http program as executable
Salvo routes.
use alux_http::HttpProgramExt;
use alux_http_salvo::SalvoHandlerImpl;
let api = SalvoHandlerImpl::new(App::new());
let router = api.compile_http(api.status_api::<App>()).into_salvo();
salvo::Server::new(salvo::conn::TcpListener::new("0.0.0.0:3000").bind().await).serve(router).await;A Salvo handler writes into the response it receives rather than returning one, so every output kind
here produces a salvo::Response for the endpoint to install. Salvo represents path captures as a
map, even when the path has only one parameter. This interpreter extracts that single value directly,
so it agrees with the path semantics of the other routers.
§Closing
Salvo owns its accept loop but accepts through a TcpAcceptor, so this crate binds the listener and hands it over. Closing therefore goes through ServerHandle::stop_graceful, which stops accepting and then waits for connections already accepted to close.
That wait takes a timeout, and it matters: Salvo drops the acceptor only once the wait is over, so stop_graceful(None) lets one client holding a connection open hold the address with it. This crate passes 5 seconds, which is what keeps close bounded and its address released.
Interprets typed HTTP programs as executable Salvo routes.
The interpretation chooses Salvo’s readers for input roles, its response for output kinds, and
Arc for the runtime handle of a semantic context. A Salvo handler writes into the response it
is given, so every output kind here answers with one.
Structs§
- Salvo
Body Input - Marks a JSON value read from the request body.
- Salvo
Bytes Output - Renders a semantic result as a raw-byte response.
- Salvo
Cookie Input - Marks a value read from the cookies a caller sent.
- Salvo
Empty Output - Renders a handler that returns nothing as a response with no body.
- Salvo
Endpoint - Erases what one endpoint does with a request Salvo routed to it.
- Salvo
File Output - Renders a semantic file result as a downloadable response.
- Salvo
Form Input - Marks a form-encoded value read from the request body.
- Salvo
Handler Impl - Interprets typed HTTP programs as executable Salvo routes.
- Salvo
Head Input - Marks a value read from the request head.
- Salvo
Header Input - Marks a value read from the headers a caller sent.
- Salvo
Header Output - Answers with a header the handler stated, beside the body it stated.
- Salvo
Html Output - Renders a semantic result as an HTML response.
- Salvo
Json Output - Renders a semantic result as a JSON response.
- Salvo
Multipart Input - Marks an argument read from a body arriving as parts.
- Salvo
Open - Carries an open Salvo server that is accepting requests.
- Salvo
Path Input - Marks a value read from the segments a path bound.
- Salvo
Query Input - Marks a value read from the query string.
- Salvo
RawBody Input - Marks the request body taken as it arrived.
- Salvo
Redirect Output - Renders a semantic location as a redirect.
- Salvo
Result Output - Answers with what a failure means when the handler failed, and with the body it states otherwise.
- Salvo
Route - Carries a composable collection of Salvo endpoints.
- Salvo
Route Impl - Interprets categorical route composition as native Salvo routing.
- Salvo
Selector - Carries route-selection meaning before it is interpreted by Salvo.
- Salvo
Server - Serves a Salvo route at the address its setup names.
- Salvo
Status Output - Answers with the status an endpoint declared, around the body it already states.
- Salvo
Stream Output - Answers with a body produced over time.
- Salvo
Text Output - Renders a semantic result as a plain-text response.
Traits§
- From
Headers Alg - Reads the handler argument the request head states.
- From
Payload Alg - Reads the handler argument a request body states, taken as it arrived.
Functions§
- salvo_
status - Interprets a portable status as the one Salvo answers with.