From 7a9fe80e4cf1a111a0b1837d0d3e789498d44b26 Mon Sep 17 00:00:00 2001 From: MohamadTahir Date: Mon, 30 Oct 2023 13:36:46 +0300 Subject: [PATCH] remove slice --- go.mod | 2 -- main.go | 10 ++++++++-- vendor/modules.txt | 2 -- 3 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 vendor/modules.txt diff --git a/go.mod b/go.mod index 20ffbe0..36c1394 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ module github.com/ditkrg/traefik-users-blocker-plugin go 1.21.3 - -require golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect diff --git a/main.go b/main.go index 58ac157..a75caf4 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( "context" "fmt" "net/http" - "slices" "strings" ) @@ -54,7 +53,14 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h func (a *UsersBlocker) ServeHTTP(rw http.ResponseWriter, req *http.Request) { userId := req.Header["X-Auth-User-Id"][0] - isUserBlocked := slices.Contains(a.userId, userId) + + var isUserBlocked bool + + for _, id := range a.userId { + if id == userId { + isUserBlocked = true + } + } if !isUserBlocked { a.next.ServeHTTP(rw, req) diff --git a/vendor/modules.txt b/vendor/modules.txt deleted file mode 100644 index 4e6acf1..0000000 --- a/vendor/modules.txt +++ /dev/null @@ -1,2 +0,0 @@ -# golang.org/x/exp v0.0.0-20231006140011-7918f672742d -## explicit; go 1.20