Expand description
High-performance Web Server Engine supporting HTTP/1.1, HTTP/2, and HTTP/3.
The server module provides the Server struct, which wraps a CompiledRouter and
dispatches incoming network streams for all supported HTTP versions.
§Protocol support
| Method | Protocol | Feature flag |
|---|---|---|
serve_http | HTTP/1.1 plain TCP (+ HTTP/2 cleartext “h2c” with http2) | (always) |
serve_https | HTTP/1.1 + HTTP/2 over TLS | tls |
serve_https_config | Same but with custom ServerConfig | tls |
serve_h3 | HTTP/3 over QUIC | http3 |
start_all | All of the above via PEM cert/key strings | cert-gen |
serve_all_acme | All of the above, certs managed by Let’s Encrypt | lets-encrypt |
serve_tor | HTTP/1.1 (+ h2c) over a native Tor .onion hidden service | tor |
serve_i2p | HTTP/1.1 (+ h2c) over a native I2P .b32.i2p eepsite (⚠️ breaks forbid(unsafe_code)) | i2p |
§Publishing over more than one transport at once
Each serve_* method above consumes its Server and blocks for that one transport’s
lifetime — the right building block for a single-transport deployment. To publish the same
app over several transports at once (e.g. clearnet HTTPS and a .onion mirror and
a .i2p mirror, all from one process), prefer MultiServer over hand-rolling
tokio::spawn + tokio::select! around the individual serve_* calls yourself — it owns
exactly that boilerplate:
use tachyon_web::{Router, Server, get};
let app: Router = Router::new().route("/", get(|| async { "hi" }));
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await?;
Server::new(app)
.with_http(listener)
// .with_onion(onion_config) // requires the `tor` feature
// .with_i2p(i2p_config) // requires the `i2p` feature
.serve()
.await?;Modules§
- i2p
- Native I2P
.b32.i2peepsite support (see thei2pfeature). - tor
- Native Tor
.onionhidden-service support (see thetorfeature).
Structs§
- Https
Server - An HTTPS server ready to be run.
- Multi
Server - Builds a group of transports to drive concurrently from one
Server— see the module docs. - Rustls
Config - Configuration for custom rustls server.
- Server
- Main server configuration and runner.
Functions§
- bind_
rustls - Create an HTTPS server bound to the given
SocketAddrusing the providedRustlsConfig. - serve
- Start serving requests from the given
TcpListenerusing the providedRouter. - serve_
http_ redirect_ and_ challenges - Runs a plain HTTP listener that serves two functions: