feat: 代理认证中间件

This commit is contained in:
tbphp
2025-07-24 17:17:18 +08:00
parent 746c9f3108
commit abb8fa1d19
3 changed files with 66 additions and 7 deletions

View File

@@ -1,6 +1,9 @@
package utils
import "fmt"
import (
"fmt"
"strings"
)
// MaskAPIKey masks an API key for safe logging.
func MaskAPIKey(key string) string {
@@ -18,3 +21,22 @@ func TruncateString(s string, maxLength int) string {
}
return s
}
// SplitAndTrim splits a string by a separator
func SplitAndTrim(s string, sep string) []string {
if s == "" {
return []string{}
}
parts := strings.Split(s, sep)
result := make([]string, 0, len(parts))
for _, part := range parts {
trimmed := strings.TrimSpace(part)
if trimmed != "" {
result = append(result, trimmed)
}
}
return result
}