| 61 | } |
| 62 | |
| 63 | func (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. |