mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-10 02:28:45 +00:00
fix(policy/checker): more explicit short-circuit
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -20,8 +20,6 @@ type List []Impl
|
||||
// It returns true only if *all* checkers return true (AND semantics).
|
||||
// If any checker returns an error, the function returns false and the error.
|
||||
func (l List) Check(r *http.Request) (bool, error) {
|
||||
// Assume success until a checker says otherwise.
|
||||
allOk := true
|
||||
for _, c := range l {
|
||||
ok, err := c.Check(r)
|
||||
if err != nil {
|
||||
@@ -31,11 +29,11 @@ func (l List) Check(r *http.Request) (bool, error) {
|
||||
if !ok {
|
||||
// One false means the combined result is false. Short-circuit
|
||||
// so we don't waste time.
|
||||
allOk = false
|
||||
break
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
return allOk, nil
|
||||
// Assume success until a checker says otherwise.
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (l List) Hash() string {
|
||||
|
||||
Reference in New Issue
Block a user