refactor: use new checker types

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-07-25 19:39:14 +00:00
parent 88c30c70fc
commit 590d8303ad
15 changed files with 331 additions and 384 deletions
-30
View File
@@ -3,11 +3,7 @@ package checker
import (
"errors"
"fmt"
"net/http"
"strings"
"github.com/TecharoHQ/anubis/internal"
)
var (
@@ -19,29 +15,3 @@ type Interface interface {
Check(*http.Request) (matches bool, err error)
Hash() string
}
type List []Interface
func (l List) Check(r *http.Request) (bool, error) {
for _, c := range l {
ok, err := c.Check(r)
if err != nil {
return ok, err
}
if ok {
return ok, nil
}
}
return false, nil
}
func (l List) Hash() string {
var sb strings.Builder
for _, c := range l {
fmt.Fprintln(&sb, c.Hash())
}
return internal.FastHash(sb.String())
}