httpserver

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReadHeaderTimeout = 5 * time.Second
	DefaultReadTimeout       = 10 * time.Second
	DefaultWriteTimeout      = 10 * time.Second
	DefaultIdleTimeout       = 60 * time.Second
	DefaultMaxHeaderBytes    = 1 << 20 // 1 MB
)

Server timeout defaults, shared with opshttp.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(opts *Options) http.Handler

NewHandler builds an HTTP handler with routes + middleware main() owns *http.Server so it can do graceful shutdown

func NewServer

func NewServer(addr string, handler http.Handler) *http.Server

func Start

func Start(ctx context.Context, opts *Options) (func(context.Context) error, error)

Start public HTTP server Returns stop(ctx) for graceful shutdown

Types

type Options

type Options struct {
	Logger       log.Logger
	Port         int
	UseRecoverMW bool
	OnPanic      func()           // Optional callback for when panics are recovered, e.g. to trigger alerts or increment prometheus counters, etc.
	APIRoutes    func(chi.Router) // Provenance API routes
	SiteHandler  http.Handler     // Main site handler
	MetricsMW    func(http.Handler) http.Handler
	RateLimitMW  func(http.Handler) http.Handler
	Health       health.Probe
	Readiness    health.Probe
	ContentInfo  httpmw.ContentInfo     // For X-Content-Bundle-Version and X-Content-Hash headers
	ClientIPOpts httpmw.ClientIPOptions // Client IP extraction options (TrustedHops, etc.)
}

Jump to

Keyboard shortcuts

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