mizu middleware command helps you discover and learn about the 100+ middlewares available for Mizu applications. Middlewares are reusable components that add functionality to your web application, such as authentication, logging, rate limiting, and security headers.
Think of middlewares as building blocks. Instead of writing code for common tasks like logging every request or checking authentication, you use a pre-built middleware that handles it for you.
Quick Examples
Subcommands
mizu middleware ls
Lists all available middlewares, grouped by category.Filter by Category
Use-c or --category to show only middlewares in a specific category:
mizu middleware show
Shows detailed information about a specific middleware, including import path, quick start code, and related middlewares.Categories
Middlewares are organized into 12 categories:| Category | Description | Examples |
|---|---|---|
| security | Authentication and security | basicauth, jwt, cors, helmet |
| logging | Request/response logging | logger, trace, audit |
| ratelimit | Rate limiting and flow control | ratelimit, throttle, bulkhead |
| cache | Caching headers and strategies | cache, etag, nocache |
| encoding | Compression and content encoding | compress, msgpack |
| resilience | Circuit breaker, retry, timeout | circuitbreaker, retry, timeout |
| routing | URL rewriting and redirects | rewrite, redirect, slash |
| content | Static files and SPA | static, spa, favicon |
| api | JSON-RPC, GraphQL, validation | jsonrpc, graphql, validator |
| session | Sessions and state | session, feature, language |
| observability | Metrics and profiling | prometheus, otel, pprof |
| misc | Other utilities | requestid, proxy, websocket |
Using a Middleware
Once you find a middleware you want to use, add it to your application:- Import the package using the import path shown by
mizu middleware show - Add the middleware using
app.Use()with the quick start code
Flags
| Flag | Description |
|---|---|
-c, --category <name> | Filter list by category |
--json | Output as JSON for scripting |
-h, --help | Show help |
JSON Output
Use--json to get machine-readable output for scripting: