feat(middleware): add path exclusion for request logging in management routes

- Excluded `/v0/management` and `/keep-alive` paths from request logging middleware for optimized performance.
This commit is contained in:
Luis Pater
2025-10-08 03:08:01 +08:00
parent 9ff21b67a8
commit d03a75dba5

View File

@@ -6,6 +6,7 @@ package middleware
import (
"bytes"
"io"
"strings"
"github.com/gin-gonic/gin"
"github.com/router-for-me/CLIProxyAPI/v6/internal/logging"
@@ -17,6 +18,12 @@ import (
// logger, the middleware has minimal overhead.
func RequestLoggingMiddleware(logger logging.RequestLogger) gin.HandlerFunc {
return func(c *gin.Context) {
path := c.Request.URL.Path
if strings.HasPrefix(path, "/v0/management") || path == "/keep-alive" {
c.Next()
return
}
// Early return if logging is disabled (zero overhead)
if !logger.IsEnabled() {
c.Next()