Function trillium_smol::config
source · [−]pub fn config() -> Config<Smol, ()>
Expand description
Configures a server before running it
Defaults
The default configuration is as follows:
- port: the contents of the
PORT
env var or else 8080 - host: the contents of the
HOST
env var or else “localhost” - signals handling and graceful shutdown: enabled on cfg(unix) systems
- tcp nodelay: disabled
- tls acceptor: none
Usage
let stopper = trillium_smol::Stopper::new();
trillium_smol::config()
.with_port(8082)
.with_host("0.0.0.0")
.without_signals()
.with_nodelay()
.with_acceptor(()) // see [`trillium_rustls`] and [`trillium_native_tls`]
.with_stopper(stopper)
.run(|conn: trillium::Conn| async move {
conn.ok("hello smol")
});
See [trillium_server_common::Config
] for more details