Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
func ListenAndServe(opts *ListenAndServeOpts) (err error)
ListenAndServe serves HTTP traffic in a sensibly default way.
By default, it serves on the env PORT or port 8080 and supports H2C. It can also be configured with self-signed SSL, useful for some providers.
func Run ¶ added in v0.1.69
func Run(opts *ListenAndServeOpts)
Run runs ListenAndServe forever, failing when shut down. This will not return.
Types ¶
type ListenAndServeOpts ¶
type ListenAndServeOpts struct {
// Addr is the address to listen on.
// If not passed, looks for the PORT env var or defaults to ":8080".
Addr string
// ServeAll hosts the server on all addresses (vs localhost) if Addr is unspecified.
ServeAll bool
// Handler is the handler to serve.
// If nil, uses [http.DefaultServeMux].
Handler http.Handler
// FakeSSL runs the handler with self-signed TLS.
// As of July 2025, this is useful for Cloudflare, which allows HTTP/2 over "bad" SSL (rather than h2c).
FakeSSL bool
}
Click to show internal directories.
Click to hide internal directories.