remove slice

This commit is contained in:
Mohamad Tahir 2023-10-30 13:36:46 +03:00
parent 465642f06f
commit 7a9fe80e4c
Signed by: MohamadTahir
GPG Key ID: 116FAB02D35512FA
3 changed files with 8 additions and 6 deletions

2
go.mod
View File

@ -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

10
main.go
View File

@ -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)

2
vendor/modules.txt vendored
View File

@ -1,2 +0,0 @@
# golang.org/x/exp v0.0.0-20231006140011-7918f672742d
## explicit; go 1.20