Skip to main content

Crate httpsd

Crate httpsd 

Source
Expand description

§httpsd

A pure-Rust HTTP/1.x server with a sans-I/O core and pluggable runtimes. The protocol engine (proto::H1Conn) performs no I/O at all — it turns bytes into Requests and serializes Responses back into bytes. Runtimes in rt move those bytes over real sockets; TLS (via purecrypto) and response compression (via compcol) are independent layers you can enable with Cargo features.

§As a library

use httpsd::{Server, Response};

let server = Server::bind("127.0.0.1:8080")?
    .handler(|req: &httpsd::Request| Response::text(format!("you asked for {}", req.path())));
server.run()?;

§Feature flags

  • tls — HTTPS via purecrypto’s sans-I/O TLS engine.
  • compress — gzip/deflate/zlib response compression via compcol.
  • config — load a ServerConfig from a TOML file.
  • cli — build the httpsd binary.
  • rt-threadpool (default), rt-tokio, rt-mio — runtime drivers.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use handler::Handler;
pub use proto::Body;
pub use proto::Headers;
pub use proto::Method;
pub use proto::Request;
pub use proto::Response;
pub use proto::StatusCode;
pub use proto::Version;
pub use session::Session;
pub use static_files::StaticFiles;
pub use config::ServerConfig;
pub use rt::Server;

Modules§

acme
Automatic TLS certificates via ACME (RFC 8555) — Let’s Encrypt and any compatible CA.
compress
Response body compression, negotiated from the request’s Accept-Encoding.
config
TOML configuration loading.
error
The crate-wide error type.
h2
HTTP/2 (RFC 9113), server side, as a sans-I/O engine.
h3
HTTP/3 (RFC 9114), server side, over QUIC.
handler
The request handler abstraction.
mime
A small static file-extension → MIME type table.
net
Networking helpers that sit beside the protocol engines: the g-dns redirect scheme and (for ACME) ClientHello inspection.
proto
The sans-I/O HTTP/1.x protocol core: value types plus the H1Conn engine.
rt
Runtime drivers: the glue that moves bytes between real sockets and the sans-I/O Session.
session
Session — the sans-I/O glue between a socket’s byte stream and a response.
static_files
A Handler that serves files from a directory on disk.
tls
TLS support, built on the sans-I/O purecrypto::tls engine.