mirror of
https://github.com/gofiber/fiber.git
synced 2025-04-27 13:14:31 +00:00
chore!: Update CSRF and Limiter to remove repetitive names The `exported` rule of revive warns to not repeat the package name in method names. For example, prefer `csrf.FromCookie` over `csrf.CsrfFromCookie`. This is a breaking change for v3. It appears that these issues will not be caught by the linter until the `exported` rule is reenabled. This requires comments on all exported symbols, which is a much broader effort.
26 lines
518 B
Go
26 lines
518 B
Go
package limiter
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v3"
|
|
)
|
|
|
|
const (
|
|
// X-RateLimit-* headers
|
|
xRateLimitLimit = "X-RateLimit-Limit"
|
|
xRateLimitRemaining = "X-RateLimit-Remaining"
|
|
xRateLimitReset = "X-RateLimit-Reset"
|
|
)
|
|
|
|
type Handler interface {
|
|
New(config Config) fiber.Handler
|
|
}
|
|
|
|
// New creates a new middleware handler
|
|
func New(config ...Config) fiber.Handler {
|
|
// Set default config
|
|
cfg := configDefault(config...)
|
|
|
|
// Return the specified middleware handler.
|
|
return cfg.LimiterMiddleware.New(cfg)
|
|
}
|