github.com/gofiber/fiber/v2@v2.47.0/docs/api/middleware/skip.md (about) 1 --- 2 id: skip 3 title: Skip 4 --- 5 6 Skip middleware for [Fiber](https://github.com/gofiber/fiber) that skips a wrapped handler if a predicate is true. 7 8 ## Signatures 9 ```go 10 func New(handler fiber.Handler, exclude func(c *fiber.Ctx) bool) fiber.Handler 11 ``` 12 13 ## Examples 14 Import the middleware package that is part of the Fiber web framework 15 ```go 16 import ( 17 "github.com/gofiber/fiber/v2" 18 "github.com/gofiber/fiber/v2/middleware/skip" 19 ) 20 ``` 21 22 After you initiate your Fiber app, you can use the following possibilities: 23 24 ```go 25 func main() { 26 app := fiber.New() 27 28 app.Use(skip.New(BasicHandler, func(ctx *fiber.Ctx) bool { 29 return ctx.Method() == fiber.MethodGet 30 })) 31 32 app.Get("/", func(ctx *fiber.Ctx) error { 33 return ctx.SendString("It was a GET request!") 34 }) 35 36 log.Fatal(app.Listen(":3000")) 37 } 38 39 func BasicHandler(ctx *fiber.Ctx) error { 40 return ctx.SendString("It was not a GET request!") 41 } 42 ``` 43 44 :::tip 45 app.Use will handle requests from any route, and any method. In the example above, it will only skip if the method is GET. 46 :::