feat(botfilter): add New
This commit is contained in:
1 parent
9ffc1d6a96
commit
b7c0d09497
1 file changed
+18
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user