release: v0.1.3
This commit is contained in:
@@ -2,6 +2,7 @@ package middleware
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"ckwk/internal/conf"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -32,7 +33,12 @@ func (w *debugBodyWriter) WriteString(data string) (int, error) {
|
||||
|
||||
func DebugHTTPLog() gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
if isDebugLogRoute(ctx.Request.URL.Path) {
|
||||
if !conf.IsRuntimeDebugEnabled() {
|
||||
ctx.Next()
|
||||
return
|
||||
}
|
||||
|
||||
if !shouldCaptureBackendRoute(ctx.Request.URL.Path) {
|
||||
ctx.Next()
|
||||
return
|
||||
}
|
||||
@@ -85,5 +91,13 @@ func truncate(value string, limit int) string {
|
||||
}
|
||||
|
||||
func isDebugLogRoute(path string) bool {
|
||||
return strings.HasPrefix(path, "/api/debug/ws/logs")
|
||||
return strings.HasPrefix(path, "/api/debug/")
|
||||
}
|
||||
|
||||
func shouldCaptureBackendRoute(path string) bool {
|
||||
if !strings.HasPrefix(path, "/api/") {
|
||||
return false
|
||||
}
|
||||
|
||||
return !isDebugLogRoute(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user