| 507 | } |
| 508 | |
| 509 | func changePath(req *http.Request, newVal func(pathOrRawPath string) string) { |
| 510 | req.URL.RawPath = newVal(req.URL.EscapedPath()) |
| 511 | if p, err := url.PathUnescape(req.URL.RawPath); err == nil && p != "" { |
| 512 | req.URL.Path = p |
| 513 | } else { |
| 514 | req.URL.Path = newVal(req.URL.Path) |
| 515 | } |
| 516 | // RawPath is only set if it's different from the normalized Path (std lib) |
| 517 | if req.URL.RawPath == req.URL.Path { |
| 518 | req.URL.RawPath = "" |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | // queryOps describes the operations to perform on query keys: add, set, rename and delete. |
| 523 | type queryOps struct { |