Skip to main content
A Mizu application is the main part of your web server.
It creates the router, manages middleware, runs the HTTP server, and handles shutdown safely when the server stops.

Create an app

Every Mizu project begins by creating an App instance.
package main

import "github.com/go-mizu/mizu"

func home(c *mizu.Ctx) error {
	return c.Text(200, "Hello, Mizu!")
}

func main() {
	app := mizu.New()
	app.Get("/", home)
	app.Listen(":3000")
}
mizu.New() creates a new app.
app.Get() adds a route.
app.Listen() starts the server on the given port.
When you visit http://localhost:3000, the server responds with “Hello, Mizu!”.

How it works

The App type includes Mizu’s Router, so you can define routes and middleware on it directly.
When Listen is called, Mizu starts a standard Go net/http server.
When the server receives a stop signal, Mizu performs a graceful shutdown and lets running requests finish first.
Mizu automatically handles:
  • Graceful shutdown when system signals are received
  • Structured logging for startup and shutdown
  • Panic recovery in handlers to prevent crashes

Health checks

You can add a health check endpoint for monitoring.
This helps detect when the server is ready or shutting down.
http.Handle("/healthz", app.HealthzHandler())
The endpoint returns 200 OK when running and 503 Service Unavailable during shutdown.
It works with load balancers and orchestration tools such as Kubernetes.

Next steps

Once your app is running, learn more about these topics:
  • Routing to define URLs and methods
  • Handler to write request logic
  • Logging to record activity and errors
  • Error to manage errors in one place