Documentation
¶
Overview ¶
Package middleware provides HTTP middleware for the PeeringDB Plus server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CORS ¶
CORS returns middleware that adds CORS headers per OPS-06. Origins are configured via the AllowedOrigins field.
func Caching ¶ added in v1.9.0
func Caching(in CachingInput) func(http.Handler) http.Handler
Caching returns middleware that sets Cache-Control and ETag headers on GET/HEAD responses, and returns 304 Not Modified for conditional requests when data has not changed since the last sync.
Only GET and HEAD methods receive caching headers. POST and other mutation methods pass through unchanged. If no successful sync has occurred (zero sync time), no caching headers are set.
Types ¶
type CORSInput ¶
type CORSInput struct {
// AllowedOrigins is a comma-separated list of allowed origins. Use "*" for all origins.
AllowedOrigins string
}
CORSInput holds configuration for the CORS middleware.
type CachingInput ¶ added in v1.9.0
type CachingInput struct {
// SyncTimeFn returns the last successful sync completion time.
// Returns zero time if no successful sync has occurred.
SyncTimeFn func() time.Time
// SyncInterval is the configured duration between automatic sync runs.
// Used to calculate Cache-Control max-age (interval + 120s buffer).
SyncInterval time.Duration
}
CachingInput holds configuration for the HTTP caching middleware.