App is the main entry point for your web server. It wraps an HTTP server, manages its lifecycle, and handles graceful shutdown when the process receives a stop signal.
What an App does
When you create an app withmizu.New(), you get:
| Component | Description |
|---|---|
| Router | Embedded, so you can call app.Get(), app.Post() directly |
| Logger | Request logging enabled by default |
| Panic recovery | Catches panics in handlers, prevents crashes |
| Graceful shutdown | Drains active requests before stopping |
Create an app
Every Mizu project starts by creating anApp:
mizu.New()creates an app with a router and default loggerapp.Get("/", ...)registers a handler for GET requests to ”/”app.Listen(":3000")starts the HTTP server
Starting the server
Mizu provides three ways to start your server:Configuration
Configure the app by setting fields after creation:| Field | Default | Description |
|---|---|---|
ShutdownTimeout | 15 seconds | Maximum time to wait for active requests to complete during shutdown |
Graceful shutdown
When your app receives a stop signal (SIGINT or SIGTERM):- New connections refused - The server stops accepting new connections
- Active requests complete - Running requests continue until finished (up to
ShutdownTimeout) - Clean exit - Server exits with success status
ShutdownTimeout, they’re terminated.
Health check endpoints
Mizu provides two health check handlers for load balancers and orchestrators like Kubernetes:| Endpoint | Normal | During Shutdown |
|---|---|---|
/livez | 200 OK | 200 OK |
/readyz | 200 OK | 503 Service Unavailable |
- Liveness (
/livez): “Is the process running?” Used by Kubernetes to decide if the pod should be restarted - Readiness (
/readyz): “Can it handle traffic?” Used by load balancers to route traffic
/readyz returns 503 so load balancers stop sending new traffic, while /livez continues returning 200 so the pod isn’t killed prematurely.
Access the underlying server
For advanced configuration, access thehttp.Server instance:
Complete example
Next steps
- Routing - Define URLs and HTTP methods
- Handler - Write request handling logic
- Middleware - Add cross-cutting behavior
- Error - Handle errors centrally