net/http design, so you can use standard handlers or write your own in a simple, composable way.
Code
Create a file namedmain.go and add this code:
Run
Start your server:-
http://localhost:8080/
Response:
Home page - no auth requiredThe logger middleware runs for this route and prints something like:INFO request completed method=GET path=/ status=200 duration=1.2ms -
http://localhost:8080/dashboard
Response:
Unauthorized -
Add a token to simulate an authenticated request:
http://localhost:8080/dashboard?token=secret
Response:
Welcome to your dashboard
How it works
Middleware in Mizu is a function that takes amizu.Handler and returns another mizu.Handler.
Each middleware can decide whether to continue to the next handler or stop early.
Every middleware gets the same
*mizu.Ctx object and can read or modify the request and response. The next(c) call runs the next function in the chain.