resolved

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package resolved is the canonical, fully-validated schema that the statute runtime operates on. It is produced by statute.Resolve from a surface Config.

All durations are time.Duration. All upstream references are pointers. All optional fields have been filled with their resolved defaults. There are no string-encoded values.

Tooling (validators, dashboards, doc generators) should target this package. End-user configurations should not — they should use the surface API in the statute package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLog

type AccessLog struct {
	Enabled bool
	Format  string // "json"
	Writer  io.Writer
	Name    string // human label for the writer

	// SampleRate is the fraction of successful requests to record, in (0,1].
	// Errors (status >= 500) and client errors (4xx) are logged regardless;
	// sampling only suppresses successful requests at high volume.
	SampleRate float64
}

AccessLog is the resolved access log configuration.

type AutoTLS

type AutoTLS struct {
	Domains []string
	Email   string
	Storage string
	DNS01   *CloudflareDNS01
}

AutoTLS is the resolved ACME configuration.

type Backend

type Backend struct {
	Address string
	Weight  int
	Backup  bool
}

Backend is a resolved backend target.

type CloudflareDNS01

type CloudflareDNS01 struct {
	APIToken string
	ZoneID   string // optional; empty means auto-discover
}

CloudflareDNS01 is the resolved DNS-01 configuration. When non-nil, the runtime uses Cloudflare's DNS API to satisfy challenges instead of HTTP-01.

type CompressAlgo

type CompressAlgo int

CompressAlgo mirrors the surface algorithm enum.

const (
	Gzip CompressAlgo = iota
	Brotli
)

Compression algorithms. Mirror statute.CompressAlgo.

type Config

type Config struct {
	Listeners     []*Listener
	Upstreams     map[string]*Pool
	Routes        []*Route
	Defaults      Defaults
	Observability Observability
	Shutdown      Shutdown
}

Config is the resolved top-level configuration.

type Defaults

type Defaults struct {
	ReadHeaderTimeout time.Duration
	ReadTimeout       time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	MaxHeaderBytes    int
}

Defaults is the resolved server defaults.

type HealthCheck

type HealthCheck struct {
	Enabled   bool
	Path      string
	Interval  time.Duration
	Timeout   time.Duration
	Healthy   int
	Unhealthy int
}

HealthCheck is a resolved active health check.

type Listener

type Listener struct {
	Addr     string
	Scheme   string // "http" or "https"
	Redirect string // non-empty: this listener is a redirect-only listener

	AutoTLS     *AutoTLS   // nil unless this is an HTTPS listener with ACME
	StaticTLS   *StaticTLS // nil unless this is an HTTPS listener with static certs
	EnableHTTP2 bool
	HTTP3Addr   string // empty unless HTTP/3 is enabled

	// BehindCloudflare indicates the listener is fronted by Cloudflare. The
	// runtime suppresses TLS-ALPN-01 challenges (HTTP-01 only) and trusts
	// CF-Connecting-IP / True-Client-IP for client IP attribution.
	BehindCloudflare bool
}

Listener is a resolved listener.

type Metrics

type Metrics struct {
	Enabled bool
	Kind    string // "prometheus"
	Addr    string
	Path    string
}

Metrics is the resolved metrics configuration.

type Middleware

type Middleware struct {
	Type MiddlewareType

	// Timeout
	Timeout time.Duration

	// RateLimit
	RateLimitPerSecond float64
	RateLimitKey       RateLimitKey

	// Retry
	RetryMax        int
	RetryOnStatuses []int

	// Cache
	CacheTTL time.Duration

	// Compress
	CompressAlgos []CompressAlgo

	// BodyLimit
	BodyLimitBytes int64

	// RequestID
	RequestIDHeader     string
	RequestIDFromHeader string

	// SecurityHeaders — each empty string means "do not emit this header".
	SecHSTS               string
	SecCSP                string
	SecFrameOptions       string
	SecContentTypeOptions bool
	SecReferrerPolicy     string
	SecPermissionsPolicy  string

	// CORS
	CORSOrigins        []string
	CORSAllowAllOrigin bool // explicit "*" in Origins
	CORSMethods        []string
	CORSHeaders        []string
	CORSExposeHeaders  []string
	CORSCredentials    bool
	CORSMaxAge         time.Duration

	// BasicAuth — users is a username -> bcrypt hash map.
	BasicAuthRealm string
	BasicAuthUsers map[string]string

	// IP allow/deny — only one direction is populated per middleware.
	IPCIDRs []string // canonical "1.2.3.0/24"
}

Middleware identifies a single resolved middleware. The Type discriminator drives runtime behaviour; only fields relevant to that type are populated.

type MiddlewareType

type MiddlewareType int

MiddlewareType discriminates resolved middleware values.

const (
	MWTimeout MiddlewareType = iota
	MWRateLimit
	MWRetry
	MWCache
	MWCompress
	MWETag
	MWBodyLimit
	MWRequestID
	MWSecurityHeaders
	MWCORS
	MWBasicAuth
	MWAllowIPs
	MWDenyIPs
)

Middleware-type discriminators. Append new entries to this list; never insert in the middle — the integer values are part of the JSON resolved export contract that downstream tooling depends on.

type Observability

type Observability struct {
	AccessLog AccessLog
	Metrics   Metrics
	Tracing   Tracing
}

Observability is the resolved observability configuration.

type Pool

type Pool struct {
	Name        string
	Backends    []Backend
	Strategy    Strategy
	HealthCheck HealthCheck
	Transport   Transport
}

Pool is a resolved upstream pool.

type RateLimitKey

type RateLimitKey int

RateLimitKey mirrors the surface key.

const (
	KeyClientIP RateLimitKey = iota
	KeyHostHeader
)

Rate-limit bucket keys. Mirror statute.RateLimitKey.

type Route

type Route struct {
	Pattern    string
	Host       string
	Upstream   *Pool  // nil for static-file routes
	StaticDir  string // empty for proxy routes
	Middleware []Middleware
}

Route is a resolved route.

type Shutdown

type Shutdown struct {
	GracePeriod    time.Duration
	DrainListeners bool
}

Shutdown is the resolved shutdown configuration.

type StaticTLS

type StaticTLS struct {
	CertFile string
	KeyFile  string
}

StaticTLS is the resolved static-cert configuration.

type Strategy

type Strategy int

Strategy mirrors the surface Strategy enum.

const (
	RoundRobin Strategy = iota
	LeastConnections
	IPHash
	Weighted
)

Load-balancing strategies. Values match the surface API constants in the statute package one-for-one; see statute.Strategy for documentation.

type Tracing

type Tracing struct {
	Enabled     bool
	Kind        string // "otlp"
	Endpoint    string
	ServiceName string
	Insecure    bool
	SampleRate  float64
}

Tracing is the resolved distributed-tracing configuration.

type Transport

type Transport struct {
	MaxIdleConnsPerHost int
	IdleConnTimeout     time.Duration
	DialTimeout         time.Duration
	TLSHandshakeTimeout time.Duration
}

Transport is a resolved transport configuration.

Jump to

Keyboard shortcuts

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