Documentation Index
Fetch the complete documentation index at: https://docs.go-mizu.dev/llms.txt
Use this file to discover all available pages before exploring further.
This guide covers production deployment considerations for Mizu mobile backends.
Environment Configuration
type Config struct {
Port string
Environment string
MinAppVersion string
MaintenanceMode bool
}
func LoadConfig() *Config {
return &Config{
Port: getEnv("PORT", "3000"),
Environment: getEnv("ENVIRONMENT", "development"),
MinAppVersion: getEnv("MIN_APP_VERSION", "1.0.0"),
MaintenanceMode: getEnv("MAINTENANCE_MODE", "false") == "true",
}
}
API Versioning Strategy
app.Use(mobile.VersionMiddleware(mobile.VersionOptions{
Header: "X-API-Version",
Supported: []mobile.Version{{3, 0}, {2, 0}},
Deprecated: []mobile.Version{{2, 0}},
Default: mobile.Version{Major: 3},
}))
Deprecation Timeline
- Month 1: Release v3, mark v2 as deprecated
- Month 2: Log v2 usage, notify users
- Month 3: Raise minimum app version
- Month 4: Remove v2 support
Response Caching
app.Use(cache.New(cache.Config{
Expiration: 5 * time.Minute,
KeyGenerator: func(c *mizu.Ctx) string {
device := mobile.DeviceFromCtx(c)
return c.Path() + ":" + device.Platform.String()
},
}))
Gzip Compression
app.Use(compress.New(compress.Config{
Level: compress.LevelBestSpeed,
}))
Monitoring
Request Logging
app.Use(func(next mizu.Handler) mizu.Handler {
return func(c *mizu.Ctx) error {
device := mobile.DeviceFromCtx(c)
start := time.Now()
err := next(c)
log.Info("request",
"path", c.Path(),
"method", c.Method(),
"status", c.Response().StatusCode,
"duration", time.Since(start),
"platform", device.Platform,
"app_version", device.AppVersion,
)
return err
}
})
Version Distribution
// Track app version distribution
metrics.RecordAppVersion(device.Platform, device.AppVersion)
Health Checks
app.Get("/health", func(c *mizu.Ctx) error {
return c.JSON(200, map[string]any{
"status": "healthy",
"time": time.Now().UTC(),
})
})
app.Get("/ready", func(c *mizu.Ctx) error {
// Check database, cache, etc.
if err := db.Ping(); err != nil {
return c.JSON(503, map[string]string{
"status": "not ready",
"error": "database unavailable",
})
}
return c.JSON(200, map[string]string{"status": "ready"})
})
Graceful Shutdown
func main() {
app := mizu.New()
setupRoutes(app)
// Graceful shutdown
app.ListenWithShutdown(":3000", 30*time.Second)
}
Next Steps
Security
Security best practices
Troubleshooting
Debug common issues