feat(botfilter): add New

This commit is contained in:
hoelee committed 2026-05-12 10:48:00 +08:00
1 parent ac7da0830c
commit 060bdff85f
1 file changed
+18
+18
View File
@@ -21,3 +21,21 @@ type botFilter struct {
logger filterLogger
}
// New constructs a Traefik middleware. Its signature is the interface used
// by Traefik's Go plugin runtime.
func New(_ context.Context, next http.Handler, config *Config, name string) (http.Handler, error) {
if next == nil {
return nil, fmt.Errorf("botfilter: next handler is nil")
}
compiled, err := compileConfig(config)
if err != nil {
return nil, err
}
return &botFilter{
next: next,
config: compiled,
cache: newClientCache(compiled),
logger: filterLogger{name: name, enabled: compiled.LogBlockedRequests},
}, nil
}