How routing works
When a request arrives at/users/42:
- Mizu checks registered routes for a match
- It finds
GET /users/{id}if you registered it - The matching handler runs with
id = "42"
ServeMux internally, which means you get the same routing patterns from the standard library with cleaner syntax.
Defining routes
Each route has three parts: an HTTP method, a path, and a handler.Available methods
Use path parameters
You can capture variable parts of a URL using braces{}.For example,
/users/{id} matches /users/42.
Handle query strings
When a URL includes a query string such as/search?q=go, you can read it with c.Query().
c.QueryValues() to read multiple parameters at once.
Group related routes
Groups help you organize routes with a common prefix, such as all/api endpoints.
/api/status and /api/users.
Mount other handlers
You can use existinghttp.Handler objects with Mizu routes.
embed package.
Customize not found behavior
If no route matches, Mizu uses a default 404 page. You can replace it with your own handler.Handle errors globally
You can define a global error handler to catch returned errors or panics.Next steps
Handler
Write request handling logic.
Context
Access request data and send responses.