Next

When Next is called, it executes the next method in the stack that matches the current route. You can pass an error struct within the method for custom error handling.

  1. c.Next(err ...error)
  1. app.Get("/", func(c *fiber.Ctx) {
  2. fmt.Println("1st route!")
  3. c.Next()
  4. })
  5.  
  6. app.Get("*", func(c *fiber.Ctx) {
  7. fmt.Println("2nd route!")
  8. c.Next(fmt.Errorf("Some error"))
  9. })
  10.  
  11. app.Get("/", func(c *fiber.Ctx) {
  12. fmt.Println(c.Error()) // => "Some error"
  13. fmt.Println("3rd route!")
  14. c.Send("Hello, World!")
  15. })