Skip to main content
Mizu provides a rich set of middlewares to handle common web application concerns. All middlewares follow these principles:
  • Zero external dependencies - Only uses Go standard library
  • Sensible defaults - Works out of the box
  • Options pattern - Fully configurable when needed
  • Concurrent safe - Safe for use across goroutines

Installation

Middlewares are included with Mizu. Import the specific middleware you need:

Quick Start

A typical production setup:

Categories

Authentication

Secure your endpoints with various authentication methods:

Security

Protect your application from common web vulnerabilities:

Rate Limiting & Resilience

Control request rates and protect against overload:

Request Processing

Validate and transform incoming requests:

Response Processing

Transform and enhance outgoing responses:

Caching

Control HTTP caching behavior:

URL Handling

Redirect and rewrite URLs:

Networking & Proxy

Handle proxy headers and reverse proxying:

Request Context

Enhance request handling:

Real-time

Support real-time communication:

Static Files

Serve static content:

Operations & Monitoring

Tools for production operations:

Advanced

Specialized functionality:

Connection & Protocol

Connection and protocol handling:

Internationalization

Locale and timezone handling:

External Integrations

Third-party service integrations:

Bot & Client Detection

Client identification and validation:

Usage Patterns

Global middleware

Apply to all routes:

Route-specific middleware

Apply to specific routes:

Group middleware

Apply to a group of routes:

Conditional middleware

Skip middleware based on conditions:

Best Practices

  1. Order matters - Place recover first to catch all panics
  2. Use timeouts - Always set request timeouts in production
  3. Rate limit - Protect public endpoints from abuse
  4. Security headers - Use helmet for recommended security headers
  5. Request IDs - Add requestid for tracing and debugging

Next Steps