secureRequestDump returns a sanitized HTTP request dump where the Authorization header, if present, is replaced with a masked value ("Authorization: *") to avoid leaking sensitive credentials. Currently, only the Authorization header is sanitized. All other headers and request data remain unchanged
(r *http.Request)
| 96 | // |
| 97 | // Currently, only the Authorization header is sanitized. All other headers and request data remain unchanged. |
| 98 | func secureRequestDump(r *http.Request) string { |
| 99 | httpRequest, _ := httputil.DumpRequest(r, false) |
| 100 | lines := strings.Split(bytesconv.BytesToString(httpRequest), "\r\n") |
| 101 | for i, line := range lines { |
| 102 | if strings.HasPrefix(line, "Authorization:") { |
| 103 | lines[i] = "Authorization: *" |
| 104 | } |
| 105 | } |
| 106 | return strings.Join(lines, "\r\n") |
| 107 | } |
| 108 | |
| 109 | func defaultHandleRecovery(c *Context, _ any) { |
| 110 | c.AbortWithStatus(http.StatusInternalServerError) |