MCPcopy Index your code
hub / github.com/ContentSquare/chproxy / newReverseProxy

Function newReverseProxy

proxy.go:52–84  ·  view source on GitHub ↗
(cfgCp *config.ConnectionPool)

Source from the content-addressed store, hash-verified

50}
51
52func newReverseProxy(cfgCp *config.ConnectionPool) *reverseProxy {
53 transport := &http.Transport{
54 Proxy: http.ProxyFromEnvironment,
55 DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
56 dialer := &net.Dialer{
57 Timeout: 30 * time.Second,
58 KeepAlive: 30 * time.Second,
59 }
60 return dialer.DialContext(ctx, network, addr)
61 },
62 ForceAttemptHTTP2: true,
63 MaxIdleConns: cfgCp.MaxIdleConns,
64 MaxIdleConnsPerHost: cfgCp.MaxIdleConnsPerHost,
65 IdleConnTimeout: 90 * time.Second,
66 TLSHandshakeTimeout: 10 * time.Second,
67 ExpectContinueTimeout: 1 * time.Second,
68 }
69
70 return &reverseProxy{
71 rp: &httputil.ReverseProxy{
72 Director: func(*http.Request) {},
73 Transport: transport,
74
75 // Suppress error logging in ReverseProxy, since all the errors
76 // are handled and logged in the code below.
77 ErrorLog: log.NilLogger,
78 },
79 reloadSignal: make(chan struct{}),
80 reloadWG: sync.WaitGroup{},
81 maxIdleConns: cfgCp.MaxIdleConnsPerHost,
82 maxIdleConnsPerHost: cfgCp.MaxIdleConnsPerHost,
83 }
84}
85
86func (rp *reverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
87 startTime := time.Now()

Callers 3

newConfiguredProxyFunction · 0.85
TestNewReverseProxyFunction · 0.85
applyConfigFunction · 0.85

Calls

no outgoing calls

Tested by 2

newConfiguredProxyFunction · 0.68
TestNewReverseProxyFunction · 0.68