Expand description
Request path: header-size limit -> rate limit (per-IP / per-route) -> auth -> per-key rate limit -> method allowlist -> body-size limit -> WAF input inspection -> forward to upstream. Response path: header injection (incl. CSP / CSP-report-only) -> cookie hardening -> strip leaky headers.
All policy lives in Runtime, held behind an ArcSwap so a config hot-reload swaps
it atomically without blocking the request path or dropping in-flight connections. The
upstream client and the metric registry sit outside the swap so the connection pool and
counters survive a reload.
Structs§
- AppState
- Shared, cheaply-cloned handle the router hands to every request. Only the hot-swappable
Runtimechanges on reload; the client and metrics are stable. - Route
Limiter - A per-route rate-limit override: requests whose path starts with
prefixuselimiter. - Runtime
- All request-handling policy derived from a
Config. Rebuilt from scratch on reload and swapped in atomically.
Constants§
- HSTS_
VALUE - The HSTS header value EdgeGuard emits when
headers.hstsis on: a two-yearmax-ageincluding subdomains. A named constant so the live proxy and the static-host config generator (crate::generate) can’t drift on it.
Functions§
- csp_
report - CSP violation report sink (
POST /__edgeguard/csp-report). Browsers POST a JSON report here whenheaders.csp_report_uripoints at it; we count and log it, then204. - handle
- metrics_
handler - Prometheus scrape endpoint (
GET /__edgeguard/metrics). Like health/ready, it is a dedicated route outside the proxy fallback, so it is not subject to auth or rate limits — restrict access to/__edgeguard/*at the network layer if that matters in your setup. - ready
- Readiness probe. Returns
200only if the upstream accepts a TCP connection, so a platform’s readiness check reflects whether EdgeGuard can actually serve traffic — not merely that the process booted.503while the upstream is unreachable. (Liveness, i.e. “is EdgeGuard itself up”, is the separate unconditional/__edgeguard/health.) - security_
headers - The constant security response headers EdgeGuard injects, derived from the
[headers]policy. This is the single source of truth shared by the live response-hardening path ([harden_response]) and the static-host config generator (crate::generate), so a generated_headersfile / edge-middleware snippet matches exactly what the proxy would add at runtime. Returns(name, value)pairs with canonically-cased names (for readable generated output); the proxy normalizes the case when it inserts them.
Type Aliases§
- Keyed
Limiter - StrLimiter
- Rate limiter keyed by the authenticated principal (per-key limiting).
- Upstream
Client