Routing
Routing connects URLs to handler functions. Mizu uses Go 1.22’s enhancedServeMux which supports path parameters natively.
- Path parameters using
{param}syntax (Go 1.22ServeMuxpatterns) - HTTP method helpers:
Get,Post,Put,Patch,Delete,Head,Connect,Trace - Route groups with
Group()andPrefix()for organizing related endpoints - Scoped middleware with
With()to apply middleware to specific routes - Mount http.Handler with
Mount()for interoperability with standard handlers
Request handling
Reading data from requests is explicit and straightforward. Each method does one thing clearly.Response helpers
Response methods write data with appropriate headers and status codes.Middleware
Middleware wraps handlers to add behavior before or after request processing. The pattern is simple: take a handler, return a handler.Logging
Mizu includes a request logger that uses Go’sslog package for structured logging.
mizu.Auto- Colored text for terminals, JSON for non-terminals (default)mizu.Dev- Human-readable text formatmizu.Prod- JSON lines for log collectors
Error handling
Handlers return errors directly. Mizu catches returned errors and recovered panics in one central place.Server lifecycle
Mizu handles graceful shutdown automatically. When your server receives SIGINT (Ctrl+C) or SIGTERM, it:- Stops accepting new connections
- Waits for active requests to complete (up to timeout)
- Shuts down cleanly