Use this file to discover all available pages before exploring further.
An 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.
package mainimport "github.com/go-mizu/mizu"func main() { // Create a new app with default settings app := mizu.New() // Define a route - App embeds Router, so this works directly app.Get("/", func(c *mizu.Ctx) error { return c.Text(200, "Hello, Mizu!") }) // Start the HTTP server on port 3000 // This blocks until you press Ctrl+C app.Listen(":3000")}
When this runs:
mizu.New() creates an app with a router and default logger
app.Get("/", ...) registers a handler for GET requests to β/β
app.Listen(":3000") starts the HTTP server
The terminal shows startup logs:
INFO server starting addr=:3000 pid=12345 go_version=go1.22
Mizu provides two health check handlers for load balancers and orchestrators like Kubernetes:
app := mizu.New()// Liveness probe: is the process alive?// Always returns 200 OKhttp.Handle("/livez", app.LivezHandler())// Readiness probe: can it handle traffic?// Returns 200 normally, 503 during shutdownhttp.Handle("/readyz", app.ReadyzHandler())app.Listen(":3000")
Endpoint
Normal
During Shutdown
/livez
200 OK
200 OK
/readyz
200 OK
503 Service Unavailable
How they differ:
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
During graceful shutdown, /readyz returns 503 so load balancers stop sending new traffic, while /livez continues returning 200 so the pod isnβt killed prematurely.
For advanced configuration, access the http.Server instance:
app := mizu.New()// Configure routes...app.Get("/", handler)// Access the server (available after calling Listen/ListenTLS/Serve)// Can be used to configure TLSConfig, ConnState callbacks, etc.srv := app.Server()