StripPrefix strips a prefix from the request URL
(prefix string, h Handler)
| 37 | |
| 38 | // StripPrefix strips a prefix from the request URL |
| 39 | func StripPrefix(prefix string, h Handler) Handler { |
| 40 | if prefix == "" { |
| 41 | return h |
| 42 | } |
| 43 | return HandlerFunc(func(ctx context.Context, w http.ResponseWriter, r *http.Request) { |
| 44 | if p := strings.TrimPrefix(r.URL.Path, prefix); len(p) < len(r.URL.Path) { |
| 45 | r.URL.Path = p |
| 46 | h.ServeHTTPContext(ctx, w, r) |
| 47 | } |
| 48 | }) |
| 49 | } |
nothing calls this directly
no test coverage detected