MCPcopy
hub / github.com/cloudflare/cloudflared / applyIngressMiddleware

Method applyIngressMiddleware

proxy/proxy.go:63–76  ·  view source on GitHub ↗
(rule *ingress.Rule, r *http.Request, w connection.ResponseWriter)

Source from the content-addressed store, hash-verified

61}
62
63func (p *Proxy) applyIngressMiddleware(rule *ingress.Rule, r *http.Request, w connection.ResponseWriter) (error, bool) {
64 for _, handler := range rule.Handlers {
65 result, err := handler.Handle(r.Context(), r)
66 if err != nil {
67 return errors.Wrap(err, fmt.Sprintf("error while processing middleware handler %s", handler.Name())), false
68 }
69
70 if result.ShouldFilterRequest {
71 _ = w.WriteRespHeaders(result.StatusCode, nil)
72 return fmt.Errorf("request filtered by middleware handler (%s) due to: %s", handler.Name(), result.Reason), true
73 }
74 }
75 return nil, true
76}
77
78// ProxyHTTP further depends on ingress rules to establish a connection with the origin service. This may be
79// a simple roundtrip or a tcp/websocket dial depending on ingres rule setup.

Callers 1

ProxyHTTPMethod · 0.95

Calls 5

ErrorfMethod · 0.80
HandleMethod · 0.65
ContextMethod · 0.65
NameMethod · 0.65
WriteRespHeadersMethod · 0.65

Tested by

no test coverage detected