diff --git a/plugins/traefik/config.go b/plugins/traefik/config.go index 3ff1c7a..5c6d1be 100644 --- a/plugins/traefik/config.go +++ b/plugins/traefik/config.go @@ -22,7 +22,6 @@ type Config struct { splittedNames []string Dynamic *DynamicConfiguration `yaml:"dynamic"` Blocking *BlockingConfiguration `yaml:"blocking"` - Next http.Handler } func CreateConfig() *Config { diff --git a/plugins/traefik/main.go b/plugins/traefik/main.go index a7bba45..c26dcaf 100644 --- a/plugins/traefik/main.go +++ b/plugins/traefik/main.go @@ -9,7 +9,7 @@ import ( type SablierMiddleware struct { client *http.Client request *http.Request - Next http.Handler + next http.Handler } // New function creates the configuration @@ -23,7 +23,7 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h return &SablierMiddleware{ request: req, client: &http.Client{}, - Next: config.Next, + next: next, }, nil } @@ -38,7 +38,7 @@ func (sm *SablierMiddleware) ServeHTTP(rw http.ResponseWriter, req *http.Request defer resp.Body.Close() if resp.Header.Get("X-Sablier-Session-Status") == "ready" { - sm.Next.ServeHTTP(rw, req) + sm.next.ServeHTTP(rw, req) } else { forward(resp, rw) } diff --git a/plugins/traefik/main_test.go b/plugins/traefik/main_test.go index af2b756..a77896b 100644 --- a/plugins/traefik/main_test.go +++ b/plugins/traefik/main_test.go @@ -33,11 +33,11 @@ func TestSablierMiddleware_ServeHTTP(t *testing.T) { body: "response from sablier", }, fields: fields{ + Next: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, "response from service") + }), Config: &Config{ Dynamic: &DynamicConfiguration{}, - Next: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, "response from service") - }), }, }, expected: "response from service", @@ -51,11 +51,11 @@ func TestSablierMiddleware_ServeHTTP(t *testing.T) { body: "response from sablier", }, fields: fields{ + Next: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, "response from service") + }), Config: &Config{ Dynamic: &DynamicConfiguration{}, - Next: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, "response from service") - }), }, }, expected: "response from sablier",