mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-14 03:35:41 +00:00
* Add support for consistent documentation using markdownlint * Only run workflow during changes to markdown files * Fix more inconsistencies * Fixes to markdown under .github/ * More fixes * Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Fix typo in limiter docs * Add missing space before code-block * Add check for dead-links * Add write-good * Remove legacy README files * Fix glob for skipping .md files * Use paths-ignore instead --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1.0 KiB
1.0 KiB
id
id |
---|
skip |
Skip
Skip middleware for Fiber that skips a wrapped handler if a predicate is true.
Signatures
func New(handler fiber.Handler, exclude func(c fiber.Ctx) bool) fiber.Handler
Examples
Import the middleware package that is part of the Fiber web framework
import (
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/skip"
)
After you initiate your Fiber app, you can use the following possibilities:
func main() {
app := fiber.New()
app.Use(skip.New(BasicHandler, func(ctx fiber.Ctx) bool {
return ctx.Method() == fiber.MethodGet
}))
app.Get("/", func(ctx fiber.Ctx) error {
return ctx.SendString("It was a GET request!")
})
log.Fatal(app.Listen(":3000"))
}
func BasicHandler(ctx fiber.Ctx) error {
return ctx.SendString("It was not a GET request!")
}
:::tip app.Use will handle requests from any route, and any method. In the example above, it will only skip if the method is GET. :::