MCPcopy
hub / github.com/cortesi/devd / StripPrefix

Function StripPrefix

httpctx/httpctx.go:39–49  ·  view source on GitHub ↗

StripPrefix strips a prefix from the request URL

(prefix string, h Handler)

Source from the content-addressed store, hash-verified

37
38// StripPrefix strips a prefix from the request URL
39func 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}

Callers

nothing calls this directly

Calls 2

HandlerFuncFuncType · 0.85
ServeHTTPContextMethod · 0.65

Tested by

no test coverage detected