Examples
Thirteen programs from the upstream MuxMaster examples directory. Each page links to the upstream source.
Thirteen runnable programs cover the production patterns MuxMaster is built for. Start with REST API for a complete bookstore service, including an HTTP QUERY (RFC 10008) search route, then read Maximum performance to see PoolRequestBundle, PoolFastParams, HandleFast, and UseFast working together, with an in-process /bench endpoint that compares a default and a pooled router on your own hardware.
The next four examples show how the pool lifetime contract shapes a program. Versioning and server-sent events run with PoolRequestBundle enabled. Upload file applies the drain-before-spawn rule to background work. Reverse proxy keeps the pool off, because a reverse proxy built on net/http.Transport is not pool-safe. The remaining seven cover authentication, caching, graceful shutdown, server-side rendering, and static files.
Every code excerpt is taken from the upstream program at the v1.3.0 tag, and every page links to the full upstream source.
-
REST API example
A MuxMaster bookstore REST API: method helpers with an HTTP QUERY (RFC 10008) search route, groups, typed parameters, error-returning handlers, and Mount.
-
Maximum-performance example
A MuxMaster program with PoolRequestBundle, PoolFastParams, HandleFast, UseFast, and pprof, plus a /bench endpoint comparing default and pooled routers.
-
Versioning example
Path-based (/api/v1, /api/v2) and header-based API versioning on one MuxMaster router, with nested admin groups and PoolRequestBundle enabled.
-
Server-sent events example
Pool-safe SSE streaming on MuxMaster: topic-hub fan-out, drop-on-slow-subscriber backpressure, periodic server tick, and an in-browser demo page.
-
Upload-file example
Multipart upload with PoolRequestBundle: single, multi, and async handlers, the drain-before-spawn pattern, 32 MiB caps, a path-traversal guard, and SHA-256.
-
Reverse-proxy example
An HTTP gateway on MuxMaster with httputil.ReverseProxy: catch-all routing, lock-free round-robin balancing, header gating, and PoolRequestBundle kept off.
-
Authentication example
HTTP Basic Authentication via the BasicAuth middleware, paired with ThrottlePerIP to defend against credential-stuffing attacks.
-
JWT example
Bearer-token authentication via the JWTAuth middleware. Configures RequireExpiry: true (RFC 8725 §4.4) and shows the canonical OIDC integration shape.
-
OAuth2 example
OAuth 2.0 token introspection (RFC 7662) via the OAuth2Introspect middleware. Tokens are validated against an authorisation server, not locally.
-
Cache example
An in-memory TTL cache that avoids re-computing identical responses within a configurable horizon. For expensive, idempotent handlers.
-
Graceful shutdown example
Production graceful shutdown: signal handling, srv.Shutdown with a bounded drain deadline, and the recommended Server timeout set for real deployments.
-
Server-side render example
A multi-page guestbook rendered by Go's html/template. The same SSR pattern that powers this documentation website you are reading now.
-
Static site example
Conditional GET (304 via ETag and Last-Modified) and range requests (206) on top of MuxMaster's ServeFiles primitive. Production static-asset semantics.