mirror of
https://github.com/ditkrg/traefik-users-blocker-plugin.git
synced 2026-01-22 20:16:53 +00:00
remove slice
This commit is contained in:
parent
465642f06f
commit
7a9fe80e4c
2
go.mod
2
go.mod
@ -1,5 +1,3 @@
|
|||||||
module github.com/ditkrg/traefik-users-blocker-plugin
|
module github.com/ditkrg/traefik-users-blocker-plugin
|
||||||
|
|
||||||
go 1.21.3
|
go 1.21.3
|
||||||
|
|
||||||
require golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
|
|
||||||
|
|||||||
10
main.go
10
main.go
@ -5,7 +5,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
|
||||||
"strings"
|
"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) {
|
func (a *UsersBlocker) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
userId := req.Header["X-Auth-User-Id"][0]
|
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 {
|
if !isUserBlocked {
|
||||||
a.next.ServeHTTP(rw, req)
|
a.next.ServeHTTP(rw, req)
|
||||||
|
|||||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -1,2 +0,0 @@
|
|||||||
# golang.org/x/exp v0.0.0-20231006140011-7918f672742d
|
|
||||||
## explicit; go 1.20
|
|
||||||
Loading…
Reference in New Issue
Block a user