proxy

package
v0.0.0-...-fb9e287 Latest Latest
Warning

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

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

Documentation

Overview

Package proxy implements the Host-based reverse proxy router.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Router)

Option configures Router construction.

func WithAccessLog

func WithAccessLog(w io.Writer) Option

WithAccessLog enables one JSON object per line written to w.

func WithMetrics

func WithMetrics(m *mgmt.Metrics) Option

WithMetrics attaches Prometheus-style counters updated per request.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router matches Host and forwards via httputil.ReverseProxy.

func NewRouter

func NewRouter(routes []config.Resolved, log *slog.Logger, opts ...Option) *Router

NewRouter builds a handler table from validated routes.

func (*Router) Reload

func (rt *Router) Reload(routes []config.Resolved)

Reload replaces the route table and clears the reverse-proxy cache. When metrics are enabled, per-host counters are synced to the new route hostnames after the lock is released.

func (*Router) RouteCount

func (rt *Router) RouteCount() int

RouteCount returns the number of configured host routes (cheap; for /_buick/health).

func (*Router) Routes

func (rt *Router) Routes() []config.Resolved

Routes returns a snapshot copy of configured routes (for management API), sorted by hostname for stable JSON from /_buick/routes.

func (*Router) ServeHTTP

func (rt *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler.

Jump to

Keyboard shortcuts

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