mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
style: replace for loops with slices.Contains
This commit is contained in:
parent
aa23b5b595
commit
dd65a8d04b
1 changed files with 4 additions and 12 deletions
|
@ -3,6 +3,8 @@ package rules
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
"github.com/yusing/go-proxy/internal/net/types"
|
"github.com/yusing/go-proxy/internal/net/types"
|
||||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||||
|
@ -47,12 +49,7 @@ var checkers = map[string]struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return func(cached Cache, r *http.Request) bool {
|
return func(cached Cache, r *http.Request) bool {
|
||||||
for _, vv := range r.Header[k] {
|
return slices.Contains(r.Header[k], v)
|
||||||
if v == vv {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -74,12 +71,7 @@ var checkers = map[string]struct {
|
||||||
}
|
}
|
||||||
return func(cached Cache, r *http.Request) bool {
|
return func(cached Cache, r *http.Request) bool {
|
||||||
queries := cached.GetQueries(r)[k]
|
queries := cached.GetQueries(r)[k]
|
||||||
for _, query := range queries {
|
return slices.Contains(queries, v)
|
||||||
if query == v {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue