httpserver

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package httpserver provides HTTP server construction helpers for the gateway.

Index

Constants

View Source
const (
	ServerReadTimeout       = 30 * time.Second
	ServerReadHeaderTimeout = 10 * time.Second
	ServerWriteTimeout      = 120 * time.Second
	ServerIdleTimeout       = 60 * time.Second
	ServerMaxHeaderBytes    = 1 << 20 // 1 MiB
)

Default HTTP server timeouts and limits.

Variables

This section is empty.

Functions

func CloseResources

func CloseResources(resources ...NamedResource) error

CloseResources closes every resource that implements io.Closer, joining any errors. It always closes the shared HTTP client idle connections last.

func NewRouter

func NewRouter(
	registry *providers.Registry,
	keyStore admin.Store,
	corsOrigins []string,
	gw *aigateway.Gateway,
	cfgManager admin.ConfigManager,
	rlStore *ratelimit.Store,
	logReader requestlog.Reader,
	logMaintainer requestlog.Maintainer,
	masterKey string,
) http.Handler

NewRouter builds the HTTP router for the gateway.

func NewServer

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

NewServer constructs an *http.Server with the standard gateway timeouts and a connection tracker wired in for Prometheus metrics.

Types

type ConnMetadata

type ConnMetadata struct {
	ID         uint64
	LocalAddr  string
	RemoteAddr string
}

ConnMetadata holds per-connection observability data stored in the request context.

func ConnMetadataFromContext

func ConnMetadataFromContext(ctx context.Context) (ConnMetadata, bool)

ConnMetadataFromContext extracts connection metadata stored by ConnContext.

type NamedResource

type NamedResource struct {
	Name  string
	Value any
}

NamedResource pairs a human-readable name with a closeable value so that close errors can be reported with context.

Jump to

Keyboard shortcuts

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