MCPcopy
hub / github.com/cortexlabs/cortex / NewReverseProxy

Function NewReverseProxy

pkg/proxy/proxy.go:28–38  ·  view source on GitHub ↗

NewReverseProxy creates a new cortex base reverse proxy

(target string, maxIdle, maxIdlePerHost int)

Source from the content-addressed store, hash-verified

26
27// NewReverseProxy creates a new cortex base reverse proxy
28func NewReverseProxy(target string, maxIdle, maxIdlePerHost int) *httputil.ReverseProxy {
29 targetURL, err := url.Parse(target)
30 if err != nil {
31 panic(err)
32 }
33
34 httpProxy := httputil.NewSingleHostReverseProxy(targetURL)
35 httpProxy.Transport = buildHTTPTransport(maxIdle, maxIdlePerHost)
36
37 return httpProxy
38}
39
40func buildHTTPTransport(maxIdle, maxIdlePerHost int) http.RoundTripper {
41 transport := http.DefaultTransport.(*http.Transport).Clone()

Callers 2

TestNewReverseProxyFunction · 0.92
mainFunction · 0.92

Calls 1

buildHTTPTransportFunction · 0.85

Tested by 1

TestNewReverseProxyFunction · 0.74