Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(cfg *Config) error

Types

type AuthConfig

type AuthConfig struct {
	Mode       string         `yaml:"mode"`        // "hmac" | "jwks"
	HMACSecret string         `yaml:"hmac_secret"` // shared secret for HS256 (hmac mode)
	JWKS       JWKSAuthConfig `yaml:"jwks"`        // jwks mode settings
}

type Config

type Config struct {
	Server    ServerConfig     `yaml:"server"`
	Upstream  UpstreamConfig   `yaml:"upstream"`
	Auth      AuthConfig       `yaml:"auth"`
	RateLimit RateLimitBackend `yaml:"rate_limit"`
	Routes    []RouteConfig    `yaml:"routes"`
}

func Load

func Load(path string) (*Config, error)

type JWKSAuthConfig

type JWKSAuthConfig struct {
	URL                string   `yaml:"url"`
	CacheTTLSeconds    int      `yaml:"cache_ttl_seconds"`
	HTTPTimeoutSeconds int      `yaml:"http_timeout_seconds"`
	LeewaySeconds      int      `yaml:"leeway_seconds"`
	Issuers            []string `yaml:"issuers"`
	Audiences          []string `yaml:"audiences"`
}

type MatchConfig

type MatchConfig struct {
	PathPrefix string `yaml:"path_prefix"`
}

type MemoryRLConfig

type MemoryRLConfig struct {
	CleanupSeconds int `yaml:"cleanup_seconds"`
	TTLSeconds     int `yaml:"ttl_seconds"`
}

type RateLimitBackend

type RateLimitBackend struct {
	Backend string         `yaml:"backend"` // "redis" | "memory"
	Redis   RedisConfig    `yaml:"redis"`
	Memory  MemoryRLConfig `yaml:"memory"`
}

type RedisConfig

type RedisConfig struct {
	Addr     string `yaml:"addr"`
	Password string `yaml:"password"`
	DB       int    `yaml:"db"`
}

type RouteCircuitBreaker

type RouteCircuitBreaker struct {
	Enabled             bool `yaml:"enabled"`
	FailureThreshold    int  `yaml:"failure_threshold"`
	OpenSeconds         int  `yaml:"open_seconds"`
	HalfOpenMaxInFlight int  `yaml:"half_open_max_in_flight"`
}

type RouteConcurrency

type RouteConcurrency struct {
	MaxInFlight int `yaml:"max_in_flight"`
}

type RouteConfig

type RouteConfig struct {
	Name           string              `yaml:"name"`
	Match          MatchConfig         `yaml:"match"`
	Upstream       string              `yaml:"upstream"`
	StripPrefix    string              `yaml:"strip_prefix"`
	AuthRequired   bool                `yaml:"auth_required"`
	RateLimit      RouteRLConfig       `yaml:"rate_limit"`
	Concurrency    RouteConcurrency    `yaml:"concurrency"`
	CircuitBreaker RouteCircuitBreaker `yaml:"circuit_breaker"`
}

type RouteRLConfig

type RouteRLConfig struct {
	Enabled bool    `yaml:"enabled"`
	RPS     float64 `yaml:"rps"`
	Burst   float64 `yaml:"burst"`
	Scope   string  `yaml:"scope"` // "user" | "ip"
}

type ServerConfig

type ServerConfig struct {
	Addr                     string   `yaml:"addr"`
	TrustedProxies           []string `yaml:"trusted_proxies"`
	MaxHeaderBytes           int      `yaml:"max_header_bytes"`
	MaxBodyBytes             int64    `yaml:"max_body_bytes"`
	ReadTimeoutSeconds       int      `yaml:"read_timeout_seconds"`
	WriteTimeoutSeconds      int      `yaml:"write_timeout_seconds"`
	IdleTimeoutSeconds       int      `yaml:"idle_timeout_seconds"`
	ReadHeaderTimeoutSeconds int      `yaml:"read_header_timeout_seconds"`
}

type UpstreamConfig

type UpstreamConfig struct {
	DialTimeoutSeconds           int `yaml:"dial_timeout_seconds"`
	TLSHandshakeTimeoutSeconds   int `yaml:"tls_handshake_timeout_seconds"`
	ResponseHeaderTimeoutSeconds int `yaml:"response_header_timeout_seconds"`
	IdleConnTimeoutSeconds       int `yaml:"idle_conn_timeout_seconds"`
	MaxIdleConns                 int `yaml:"max_idle_conns"`
	MaxIdleConnsPerHost          int `yaml:"max_idle_conns_per_host"`
}

Jump to

Keyboard shortcuts

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