feat: Add deprecation middleware for legacy endpoints
- Create middleware/deprecation.go with DeprecationMiddleware - Adds Warning and Deprecation headers to old endpoints - Apply middleware to all non-/api/v1 routes: /version, /dbtest, /health, /character*, /download*, /sync/*, /music/* - Message: 'Deprecated: This endpoint is deprecated. Use /api/v1/ endpoints instead.' Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v5"
|
||||
)
|
||||
|
||||
// DeprecationMiddleware adds deprecation warning to responses
|
||||
// for old endpoints that are being phased out in favor of /api/v1/*
|
||||
func DeprecationMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c *echo.Context) error {
|
||||
// Add deprecation warning header
|
||||
c.Response().Header().Add("Warning", `299 - "Deprecated: This endpoint is deprecated. Use /api/v1/ endpoints instead."`)
|
||||
c.Response().Header().Add("Deprecation", "true")
|
||||
return next(c)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user