perf(all): use strings.Cut to replace strings.SplitN (#4239)

Co-authored-by: 1911860538 <alxps1911@gmail.com>
This commit is contained in:
Name
2025-05-20 22:58:34 +08:00
committed by GitHub
parent 2e2bd1f408
commit 3d8e288c64
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -74,9 +74,9 @@ func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
httpRequest, _ := httputil.DumpRequest(c.Request, false)
headers := strings.Split(string(httpRequest), "\r\n")
for idx, header := range headers {
current := strings.Split(header, ":")
if current[0] == "Authorization" {
headers[idx] = current[0] + ": *"
key, _, _ := strings.Cut(header, ":")
if key == "Authorization" {
headers[idx] = key + ": *"
}
}
headersToStr := strings.Join(headers, "\r\n")