Update middleware demo

pull/6/head
Fenny 2020-01-21 00:59:01 +01:00
parent 7041f051e1
commit cc759981eb
1 changed files with 6 additions and 7 deletions

View File

@ -84,17 +84,16 @@ import "github.com/gofiber/fiber"
func main() {
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) {
c.Set("random-header", "random-value")
c.Write("1st route!\n")
app.Use(func(c *fiber.Ctx) {
c.Write("Match anything!\n")
c.Next()
})
app.Get("/", func(c *fiber.Ctx) {
c.Write("2nd route!\n")
app.Use("/api", func(c *fiber.Ctx) {
c.Write("Match starting with /api\n")
c.Next()
})
app.Get("/", func(c *fiber.Ctx) {
c.Write("3rd route!\n")
app.Get("/api/user", func(c *fiber.Ctx) {
c.Write("Match exact path /api/user\n")
})