Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CORS ¶
CORS reflects the request Origin on the public OAuth/MCP surface (/oauth/*, /.well-known/*, /mcp) for browser-based public clients. Credentials are never allowed — Bearer JWT + PKCE secures these endpoints, so no credentialed-origin allowlist is kept (unlike hilo). Other paths get no CORS headers.
func MaxBytes ¶
MaxBytes wraps r.Body in an http.MaxBytesReader so an oversized body fails at the ceiling instead of being fully buffered (or embedded on the /api path). Covers the /api JSON decode and /mcp streamable paths. n <= 0 disables the cap.
func RateLimit ¶
func RateLimit(cfg RateLimitConfig) func(http.Handler) http.Handler
RateLimit is a token-bucket throttle keyed by the trusted client IP, reading rps/burst/proxy-depth live from cfg per request; rps <= 0 or a nil cfg disables it, and the limiter is rebuilt only when rps or burst change.
func SecurityHeaders ¶
SecurityHeaders sets the CSP plus nosniff/no-referrer on every response. Outermost layer, so 429/413/OPTIONS responses carry them too; defence in depth behind the UI's DOMPurify — even a sanitizer bypass can't load an off-origin script.
Types ¶
type RateLimitConfig ¶ added in v1.1.1
type RateLimitConfig interface {
RateLimitRPS() float64
RateLimitBurst() int
TrustedProxyDepth() int
}
RateLimitConfig supplies the live rate-limit knobs, read per request so a config change applies without a restart. RPS <= 0 disables the throttle.