SanitizeRequestURL will return a sanitised string of the URL by: - Tagging mux path variables. - Tagging query parameters. - Replacing sensitive data from the URL query string with ******. Have to use string replacement instead of writing directly to the Values URL object, as only the URL's raw quer
(req *http.Request, cachedQueryValues *url.Values)
| 720 | // - Replacing sensitive data from the URL query string with ******. |
| 721 | // Have to use string replacement instead of writing directly to the Values URL object, as only the URL's raw query is mutable. |
| 722 | func SanitizeRequestURL(req *http.Request, cachedQueryValues *url.Values) string { |
| 723 | |
| 724 | // Populate a cached copy of query values if nothing is passed in. |
| 725 | if cachedQueryValues == nil { |
| 726 | v := req.URL.Query() |
| 727 | cachedQueryValues = &v |
| 728 | } |
| 729 | |
| 730 | urlString := sanitizeRequestURLQueryParams(req.URL.String(), *cachedQueryValues) |
| 731 | |
| 732 | if RedactSystemData || RedactMetadata || RedactUserData { |
| 733 | tagQueryParams(*cachedQueryValues, &urlString) |
| 734 | tagPathVars(req, &urlString) |
| 735 | } |
| 736 | |
| 737 | return urlString |
| 738 | } |
| 739 | |
| 740 | // redactedPathVars is a lookup map of path variables to redaction types. |
| 741 | var redactedPathVars = map[string]string{ |