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

Function NewHTTPReverseProxy

client/proxy/Proxy.go:73–87  ·  view source on GitHub ↗
(serverAddr string, transport http.RoundTripper, enforcer casbin.Enforcer)

Source from the content-addressed store, hash-verified

71}
72
73func NewHTTPReverseProxy(serverAddr string, transport http.RoundTripper, enforcer casbin.Enforcer) (func(writer http.ResponseWriter, request *http.Request), error) {
74 proxy, err := GetProxyServer(serverAddr, transport, Proxy)
75 if err != nil {
76 return nil, err
77 }
78 return func(w http.ResponseWriter, r *http.Request) {
79
80 token := r.Header.Get("token")
81 if ok := enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*"); !ok {
82 common.WriteJsonResp(w, nil, "Unauthorized User", http.StatusForbidden)
83 return
84 }
85 proxy.ServeHTTP(w, r)
86 }, nil
87}

Callers 1

NewProxyRouterImplFunction · 0.85

Calls 4

WriteJsonRespFunction · 0.92
GetProxyServerFunction · 0.85
GetMethod · 0.65
EnforceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…