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

Function NewProxyRouterImpl

client/proxy/ProxyRouter.go:55–86  ·  view source on GitHub ↗
(logger *zap.SugaredLogger, proxyCfg *Config, enforcer casbin.Enforcer)

Source from the content-addressed store, hash-verified

53}
54
55func NewProxyRouterImpl(logger *zap.SugaredLogger, proxyCfg *Config, enforcer casbin.Enforcer) (*ProxyRouterImpl, error) {
56 client := &http.Client{
57 Transport: &http.Transport{
58 Proxy: http.ProxyFromEnvironment,
59 Dial: (&net.Dialer{
60 Timeout: 120 * time.Second,
61 KeepAlive: 120 * time.Second,
62 }).Dial,
63 TLSHandshakeTimeout: 10 * time.Second,
64 ExpectContinueTimeout: 1 * time.Second,
65 },
66 }
67 proxyConnection := make(map[string]ProxyConnection)
68 err := json.Unmarshal([]byte(proxyCfg.ProxyServiceConfig), &proxyConnection)
69 if err != nil {
70 logger.Warnw("bad env value for PROXY_SERVICE_CONFIG", "err", err)
71 }
72
73 proxy := make(map[string]func(writer http.ResponseWriter, request *http.Request))
74 for s, connection := range proxyConnection {
75 proxy[s], err = NewHTTPReverseProxy(fmt.Sprintf("http://%s:%s", connection.Host, connection.Port), client.Transport, enforcer)
76 if err != nil {
77 return nil, err
78 }
79 }
80
81 router := &ProxyRouterImpl{
82 proxy: proxy,
83 logger: logger,
84 }
85 return router, nil
86}
87
88func (router ProxyRouterImpl) InitProxyRouter(ProxyRouter *mux.Router) {
89

Callers 1

InitializeAppFunction · 0.92

Calls 1

NewHTTPReverseProxyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…