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 ¶
- type AccessLog
- type AutoTLS
- type Backend
- type CloudflareDNS01
- type CompressAlgo
- type Config
- type Defaults
- type HealthCheck
- type Listener
- type Metrics
- type Middleware
- type MiddlewareType
- type Observability
- type Pool
- type RateLimitKey
- type Route
- type Shutdown
- type StaticTLS
- type Strategy
- type Tracing
- type Transport
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 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 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 ¶
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.