MCPcopy
hub / github.com/openfaas/faas / makeRewriteProxy

Function makeRewriteProxy

gateway/handlers/forwarding_proxy.go:208–227  ·  view source on GitHub ↗
(baseURLResolver middleware.BaseURLResolver, urlPathTransformer middleware.URLPathTransformer)

Source from the content-addressed store, hash-verified

206}
207
208func makeRewriteProxy(baseURLResolver middleware.BaseURLResolver, urlPathTransformer middleware.URLPathTransformer) *httputil.ReverseProxy {
209
210 return &httputil.ReverseProxy{
211
212 ErrorLog: log.New(io.Discard, "proxy:", 0),
213 ErrorHandler: func(w http.ResponseWriter, r *http.Request, err error) {
214 },
215 Director: func(r *http.Request) {
216
217 baseURL := baseURLResolver.Resolve(r)
218 baseURLu, _ := r.URL.Parse(baseURL)
219
220 requestURL := urlPathTransformer.Transform(r)
221
222 r.URL.Scheme = "http"
223 r.URL.Path = requestURL
224 r.URL.Host = baseURLu.Host
225 },
226 }
227}

Callers 1

Calls 2

ResolveMethod · 0.65
TransformMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…