Documentation
¶
Overview ¶
Package server owns the listener and the HTTP server lifecycle.
Index ¶
- func AccessLog(next http.Handler, log RequestLogger) http.Handler
- func Listen(ip net.IP, port int) (net.Listener, error)
- func NewHandler(cfg *config.Config, api Routes) http.Handler
- func Serve(ctx context.Context, ln net.Listener, handler http.Handler, ...) error
- func URLs(ip net.IP, port int) ([]string, error)
- type PortInUseError
- type RequestLogger
- type Routes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessLog ¶
func AccessLog(next http.Handler, log RequestLogger) http.Handler
AccessLog wraps next and reports every request to log once it finishes. It sits outermost, so rejections by the origin guard and auth are logged too.
func Listen ¶
Listen binds ip:port. It uses tcp4 or tcp6 to match the address family of ip, so binding 0.0.0.0 never quietly becomes a dual-stack socket that also listens on IPv6 addresses the startup output did not print.
func NewHandler ¶
NewHandler builds the /api/v2 router wrapped in the middleware chain. api may be nil, which serves health alone.
func Serve ¶
Serve runs handler on ln until ctx is cancelled, then drains in-flight requests for up to shutdownTimeout. onShutdown hooks run as shutdown starts; long-lived responses such as SSE streams use them to end, since they would otherwise hold the drain open until the timeout.
func URLs ¶
URLs lists every base URL the proxy is reachable at when bound to ip:port. A wildcard bind expands to loopback plus the address of each interface that is up, in the bound family, skipping container and VM bridges. IPv6 link-local addresses are skipped because they are unusable in a URL without a zone.
Types ¶
type PortInUseError ¶
PortInUseError reports that the configured port is already bound. The proxy never falls back to another port: SDK clients are pointed at a fixed one, and a port that moves silently breaks them.
func (*PortInUseError) Error ¶
func (e *PortInUseError) Error() string
func (*PortInUseError) Unwrap ¶
func (e *PortInUseError) Unwrap() error
type RequestLogger ¶
RequestLogger receives one entry per finished request.