server

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server owns the listener and the HTTP server lifecycle.

Index

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

func Listen(ip net.IP, port int) (net.Listener, error)

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

func NewHandler(cfg *config.Config, api Routes) http.Handler

NewHandler builds the /api/v2 router wrapped in the middleware chain. api may be nil, which serves health alone.

func Serve

func Serve(ctx context.Context, ln net.Listener, handler http.Handler, onShutdown ...func()) error

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

func URLs(ip net.IP, port int) ([]string, error)

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

type PortInUseError struct {
	Addr string
	Err  error
}

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

type RequestLogger func(at time.Time, method, path string, status int, took time.Duration)

RequestLogger receives one entry per finished request.

type Routes

type Routes interface {
	Register(mux *http.ServeMux)
}

Routes registers the v2 surface on a mux.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL