TUN-6775: Add middleware.Handler verification to ProxyHTTP

ProxyHTTP now processes middleware Handler before executing the request.
A chain of handlers is now executed and appropriate response status
codes are sent.
This commit is contained in:
Sudarsan Reddy
2022-09-22 15:11:59 +01:00
parent 9bb7628fbc
commit 7f487c2651
5 changed files with 54 additions and 26 deletions

View File

@@ -5,6 +5,15 @@ import (
"net/http"
)
type Handler interface {
Handle(ctx context.Context, r *http.Request) error
type HandleResult struct {
// Tells that the request didn't passed the handler and should be filtered
ShouldFilterRequest bool
// The status code to return in case ShouldFilterRequest is true.
StatusCode int
Reason string
}
type Handler interface {
Name() string
Handle(ctx context.Context, r *http.Request) (result *HandleResult, err error)
}