Add rate limiter, rename maxConn into inFlightReq
Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com> Co-authored-by: Jean-Baptiste Doumenjou <jb.doumenjou@gmail.com>
This commit is contained in:
parent
a8c73f7baf
commit
4ec90c5c0d
30 changed files with 1419 additions and 651 deletions
|
@ -17,9 +17,10 @@ import (
|
|||
"github.com/containous/traefik/v2/pkg/middlewares/compress"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/customerrors"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/headers"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/inflightreq"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/ipwhitelist"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/maxconnection"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/passtlsclientcert"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/ratelimiter"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/redirect"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/replacepath"
|
||||
"github.com/containous/traefik/v2/pkg/middlewares/replacepathregex"
|
||||
|
@ -122,7 +123,7 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) (
|
|||
}
|
||||
|
||||
// Buffering
|
||||
if config.Buffering != nil && config.MaxConn.Amount != 0 {
|
||||
if config.Buffering != nil && config.InFlightReq.Amount != 0 {
|
||||
if middleware != nil {
|
||||
return nil, badConf
|
||||
}
|
||||
|
@ -211,13 +212,13 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) (
|
|||
}
|
||||
}
|
||||
|
||||
// MaxConn
|
||||
if config.MaxConn != nil && config.MaxConn.Amount != 0 {
|
||||
// InFlightReq
|
||||
if config.InFlightReq != nil && config.InFlightReq.Amount != 0 {
|
||||
if middleware != nil {
|
||||
return nil, badConf
|
||||
}
|
||||
middleware = func(next http.Handler) (http.Handler, error) {
|
||||
return maxconnection.New(ctx, next, *config.MaxConn, middlewareName)
|
||||
return inflightreq.New(ctx, next, *config.InFlightReq, middlewareName)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,16 +232,15 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) (
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: disable temporarily (rateLimit)
|
||||
// RateLimit
|
||||
// if config.RateLimit != nil {
|
||||
// if middleware != nil {
|
||||
// return nil, badConf
|
||||
// }
|
||||
// middleware = func(next http.Handler) (http.Handler, error) {
|
||||
// return ratelimiter.New(ctx, next, *config.RateLimit, middlewareName)
|
||||
// }
|
||||
// }
|
||||
if config.RateLimit != nil {
|
||||
if middleware != nil {
|
||||
return nil, badConf
|
||||
}
|
||||
middleware = func(next http.Handler) (http.Handler, error) {
|
||||
return ratelimiter.New(ctx, next, *config.RateLimit, middlewareName)
|
||||
}
|
||||
}
|
||||
|
||||
// RedirectRegex
|
||||
if config.RedirectRegex != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue