Skip to main content

Module http

Module http 

Source
Expand description

A native HTTP/1.1 server — the runtime a LOGOS program’s Serve statement executes on.

Two layers, split so the protocol is swappable:

  • wire is a pure, dependency-free HTTP/1.1 parser + writer over plain byte buffers (hand-rolled, matching the repo’s self-contained crypto ethos — no hyper): the server half (parse_request/serialize_response) and its exact client-side mirror (serialize_request/parse_response).
  • server (added alongside) is a tokio accept loop generic over a handler, sitting behind an internal transport boundary so a hyper-backed transport can drop in later without touching the LOGOS handler bridge or the wire types.

Above them, engine holds the ENGINE knob: the serve entries pick between the portable tokio loop and the Linux thread-per-core io_uring engine (engine_uring, behind the io-uring feature) via LOGOS_HTTP_ENGINE, defaulting to the fast path wherever a ring initializes — always announced on stderr, and byte-identical on the wire (both engines speak through the same wire core).

Native only, behind the http feature.

Re-exports§

pub use engine::EngineChoice;
pub use engine::EngineKind;
pub use engine::StaticResponses;
pub use lifecycle::service_unavailable;
pub use lifecycle::shutdown_requested;
pub use lifecycle::Admission;
pub use lifecycle::DrainOutcome;
pub use lifecycle::Lifecycle;
pub use lifecycle::LifecycleConfig;
pub use lifecycle::CORRELATION_HEADER;
pub use server::serve;
pub use server::serve_with_statics;
pub use server::spawn;
pub use server::spawn_with_lifecycle;
pub use server::Conn;
pub use server::HttpServer;
pub use server::Listener;
pub use server::ReadError;
pub use wire::parse_request;
pub use wire::parse_response;
pub use wire::serialize_request;
pub use wire::serialize_response;
pub use wire::HttpRequest;
pub use wire::HttpResponse;
pub use wire::ParseError;
pub use wire::MAX_BODY;

Modules§

engine
Engine selection + the pre-serialized static-response table — the cross-platform half of the HTTP fast path.
lifecycle
The production server LIFECYCLE — the shared state machine that makes a LOGOS Serve “serious and stays serving”: it drains gracefully (never drops an in-flight request), gates readiness separately from liveness, sheds load with bounded backpressure (503, never an unbounded hang), bounds per-request time, survives malformed floods, and stamps every response/log line with a correlation id (secret-safe).
server
The tokio accept loop — the runtime under a LOGOS Serve.
wire
HTTP/1.1 wire format — hand-rolled parsers and writers over plain byte buffers. No hyper, no allocations beyond the owned result. The server half is parse_request + serialize_response; the client half is its exact mirror, serialize_request + parse_response — same error taxonomy, same limits, same ParseError::Incomplete retry contract.