Skip to content

std/https ​

An HTTPS server: std/http's routes and wire format driven over std/tls. It is a separate module so a plain HTTP server links without OpenSSL; importing std/https is what pulls it in.

milo
from "std/https" import { serveTls, serveRouterTls }

API reference ​

serveRouterTls ​

milo
pub fn serveRouterTls(port: u16?, certPath: &string, keyPath: &string, router: &Router): Result<Unit>

serveRouter over TLS: routes, Context-set headers and the router's body limits behave exactly as in std/http.

serveRouterTlsWith ​

milo
pub fn serveRouterTlsWith(port: u16?, certPath: &string, keyPath: &string, router: &Router, opts: &ServeOptions): Result<Unit>

serveRouterTls with its limits spelled out (ServeOptions): the connection cap, the read timeout (applied to the handshake, then afresh to the request), the write timeout and the SIGTERM drain, all as in http.serveRouterWith.

serveTls ​

milo
pub fn serveTls(port: u16?, certPath: &string, keyPath: &string, handler: (&Request) => Response): Result<Unit>

Serve HTTPS on port (None = OS-chosen) with the PEM cert chain and private key at certPath/keyPath. One request per connection, closed after the response, read with std/http's own reader (chunked and gzip/deflate bodies, the 1 MiB body cap and the 400/413/414/431/501/505 refusals). Each connection, handshake included, runs in its own green task under ServeOptions' defaults (connection cap, read and write timeouts, SIGTERM drain): the same contract as http.serveRouter. Only returns on a fatal bind/listen error.