MCPcopy
hub / github.com/devtron-labs/devtron / GetProxyServer

Function GetProxyServer

client/proxy/Proxy.go:43–59  ·  view source on GitHub ↗
(serverAddr string, transport http.RoundTripper, pathToExclude string)

Source from the content-addressed store, hash-verified

41}
42
43func GetProxyServer(serverAddr string, transport http.RoundTripper, pathToExclude string) (*httputil.ReverseProxy, error) {
44 target, err := url.Parse(serverAddr)
45 if err != nil {
46 log.Println(err)
47 return nil, err
48 }
49 proxy := httputil.NewSingleHostReverseProxy(target)
50 proxy.Transport = transport
51 proxy.Director = func(request *http.Request) {
52 path := request.URL.Path
53 request.URL.Host = target.Host
54 request.URL.Scheme = target.Scheme
55 request.URL.Path = rewriteRequestUrl(path, pathToExclude)
56 fmt.Printf("%s\n", request.URL.Path)
57 }
58 return proxy, nil
59}
60
61func rewriteRequestUrl(path string, pathToExclude string) string {
62 parts := strings.Split(path, "/")

Callers 2

NewHTTPReverseProxyFunction · 0.85

Calls 1

rewriteRequestUrlFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…