mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
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:
@@ -6,6 +6,7 @@ package middleware
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/logging"
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/logging"
|
||||||
@@ -17,6 +18,12 @@ import (
|
|||||||
// logger, the middleware has minimal overhead.
|
// logger, the middleware has minimal overhead.
|
||||||
func RequestLoggingMiddleware(logger logging.RequestLogger) gin.HandlerFunc {
|
func RequestLoggingMiddleware(logger logging.RequestLogger) gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
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)
|
// Early return if logging is disabled (zero overhead)
|
||||||
if !logger.IsEnabled() {
|
if !logger.IsEnabled() {
|
||||||
c.Next()
|
c.Next()
|
||||||
|
|||||||
Reference in New Issue
Block a user