mirror of
https://github.com/zap-proto/fiber.git
synced 2026-10-30 15:06:23 +00:00
Fork of gofiber/fiber v3 based on the v3.2.0 tag. Rewrites all self-imports github.com/gofiber/fiber/v3 -> github.com/zap-proto/fiber/v3. Upstream gofiber/schema and gofiber/utils/v2 dependencies are left untouched. Co-authored-by: Hanzo Dev <[email protected]>
23 lines
481 B
Go
23 lines
481 B
Go
package skip
|
|
|
|
import (
|
|
"github.com/zap-proto/fiber/v3"
|
|
)
|
|
|
|
// New returns a middleware that calls the provided predicate for each request.
|
|
// If the predicate evaluates to true the wrapped handler is skipped and the next
|
|
// handler in the chain is executed.
|
|
func New(handler fiber.Handler, exclude func(c fiber.Ctx) bool) fiber.Handler {
|
|
if exclude == nil {
|
|
return handler
|
|
}
|
|
|
|
return func(c fiber.Ctx) error {
|
|
if exclude(c) {
|
|
return c.Next()
|
|
}
|
|
|
|
return handler(c)
|
|
}
|
|
}
|