Examples
Eight 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 the canonical CRUD service, then jump straight to Maximum performance to see every v1.1.0 opt-in working together (PoolRequestBundle, PoolFastParams, HandleFast, UseFast, plus an in-process /bench endpoint that reports the speed-up on your hardware).
The four v1.1.0 patterns under it — versioning, server-sent events, upload file, reverse proxy — each demonstrate a different way to satisfy the pool lifetime contract: synchronous handlers, long-lived streams, the drain-before-spawn rule for background work, and synchronous proxying. The remaining seven cover authentication, caching, operational concerns, and content rendering.
Every example mirrors its upstream main.go at the v1.1.0 tag verbatim — the code is the source of truth.
-
REST API example
A complete REST API built with MuxMaster: route grouping, JSON responses, parameter parsing, and a small in-memory store. CRUD over a single resource.
-
Maximum-performance example
Every v1.1.0 opt-in combined: PoolRequestBundle, PoolFastParams, HandleFast, UseFast, Mounted pprof, plus an in-process /bench endpoint that reports the live 2.4x speed-up.
-
Versioning example
Path-based (/v1, /v2) and header-based (Accept: ...;v=N) API versioning on the same router, with nested admin groups and PoolRequestBundle for zero-alloc dispatch.
-
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 + async handlers, the body-drain-before-spawn pattern, 32 MiB caps, path-traversal guard, streaming SHA-256.
-
Reverse-proxy example
HTTP gateway with httputil.ReverseProxy on MuxMaster: catch-all routing, lock-free round-robin load balancing, per-route gating, and pool-safe synchronous dispatch.
-
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.