3418f492f5
- 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>
17 lines
534 B
Go
17 lines
534 B
Go
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)
|
|
}
|
|
}
|