Skip to content

Examples

Each example is a small runnable server in examples/, with its own tests. Run one with go run ./examples/<name>; the curl commands to try it are in the comment at the top of each file.

Example Shows
basic The middleware, plus the admin API on a separate internal port. The getting-started guide walks through it.
admin-auth The app and the admin API on one port, with bearer-token auth and the admin API mounted outside the middleware, so a broad rule can't lock you out.
filewatch Rules loaded from a JSON file and reloaded when it changes: the Kubernetes ConfigMap pattern.
auto A health loop that browns out an endpoint when its dependency fails and restores it when the dependency recovers, with a TTL as the fallback.
degrade Check used to skip an expensive step and serve a cheaper page instead of a 503.
metrics Shed requests counted per rule with WithOnShed, and JSON error bodies from WithResponder.

There are also runnable snippets in example_test.go, which appear on pkg.go.dev.