Expand description
§alux-http-actix
alux-http-actix interprets an alux-http program as executable
actix-web routes.
use actix_web::{App, HttpServer};
use alux_http::HttpProgramExt;
use alux_http_actix::ActixHandlerImpl;
let api = ActixHandlerImpl::new(App::new());
let configure = api.compile_http(api.status_api::<App>()).into_actix();
HttpServer::new(move || App::new().configure(configure.clone())).bind(("0.0.0.0", 3000))?.run().await?;actix-web creates its services again for every worker, and an actix_web::Route cannot be cloned or
reused. The interpreter therefore keeps the logic for constructing each endpoint and rebuilds the
routes for every worker. Shared state reaches a handler as the semantic context from the program,
not as actix_web::Data, so framework types stay out of the specification.
§Accepting
actix-web accepts on a socket this interpreter binds and hands over through HttpServer::listen, but it serves that socket from runtimes of its own: an actix-rt System with one current-thread Tokio runtime per worker thread. It exposes no entry point that takes a single connection, so the accept loop belongs to actix and cannot be driven from outside.
Stopping therefore goes through ServerHandle::stop. Dropping the task that awaits the server reaches neither the workers nor the socket they accept on, so the address would stay bound.
§Signals
This interpreter calls HttpServer::disable_signals, because whoever opened the server is the one who decides when it closes.
Left on, actix-web installs process-wide handlers and answers Ctrl-C and SIGTERM itself: its accept loop turns SIGTERM into a graceful stop and SIGINT into a forced one. An application built on alux-http never sees either, so its own shutdown never runs and kill or pkill appears to do nothing at all. Ending a server is what HttpServerAlg::close and HttpServerAlg::end are for, and a signal is the application’s to interpret.
Interprets typed HTTP programs as executable actix-web routes.
The interpretation chooses actix-web’s extractors for input roles, its responses for output
kinds, and Arc for the runtime handle of a semantic context. It also states an endpoint as what
makes one, because actix-web configures its routes again for every worker.
Structs§
- Actix
Body Input - Marks a JSON value extracted from the request body by actix-web.
- Actix
Bytes Output - Renders a semantic result as a raw-byte response.
- Actix
Cookie Input - Marks a value read from the cookies a caller sent.
- Actix
Empty Output - Renders a handler that returns nothing as a response with no body.
- Actix
Endpoint - States an endpoint as what makes one, because actix-web builds its routes once per worker.
- Actix
File Output - Renders a semantic file result as a downloadable response.
- Actix
Form Input - Marks a form-encoded value extracted from the request body by actix-web.
- Actix
Handler Impl - Interprets typed HTTP programs as executable actix-web routes.
- Actix
Header Input - Marks a value read from the headers a caller sent.
- Actix
Header Output - Answers with a header the handler stated, beside the body it stated.
- Actix
Html Output - Renders a semantic result as an HTML response.
- Actix
Json Output - Renders a semantic result as a JSON response.
- Actix
Multipart Input - Marks an argument read from a body arriving as parts.
- Actix
Open - Carries an open actix-web server that is accepting requests.
- Actix
Path Input - Marks a value extracted from the request path by actix-web.
- Actix
Query Input - Marks a value extracted from the query string by actix-web.
- Actix
Redirect Output - Renders a semantic location as a redirect.
- Actix
Request Input - Marks a value extracted through actix-web’s own request extractor.
- Actix
Result Output - Answers with what a failure means when the handler failed, and with the body it states otherwise.
- Actix
Route - Carries a composable collection of actix-web routes, as what makes them.
- Actix
Route Impl - Interprets categorical route composition as native actix-web routing.
- Actix
Selector - Carries route-selection meaning before it is registered with actix-web.
- Actix
Server - Serves an actix-web route at the address its setup names.
- Actix
Status Output - Answers with the status an endpoint declared, around the body it already states.
- Actix
Stream Output - Answers with a body produced over time.
- Actix
Text Output - Renders a semantic result as a plain-text response.
Functions§
- actix_
status - Interprets a portable status as the one actix-web answers with.
- not_
found - Answers whatever nothing else did, which is how a surface states that it did not.