-
-
Notifications
You must be signed in to change notification settings - Fork 2k
🤗 Is there a way to get the final route path in the middleware of the group #923
Copy link
Copy link
Closed
Labels
Description
Question description
go v1.15.1
fiber v2.0.6
Code snippet Optional
package main
import (
"fmt"
"github.com/gofiber/fiber/v2"
)
func handler(ctx *fiber.Ctx) error {
fmt.Println(ctx.Route().Path)
// output2: /api/v1/user/:ID
return ctx.SendString("ok")
}
func main() {
app := fiber.New()
api := app.Group("/api") // /api
v1 := api.Group("/v1") // /api/v1
v1.Use(func(ctx *fiber.Ctx) error {
fmt.Println(ctx.Route().Path)
// output1: /api/v1
return ctx.Next()
})
v1.Get("/list", handler) // /api/v1/list
v1.Get("/user/:ID", handler) // /api/v1/user
v2 := api.Group("/v2") // /api/v2
v2.Get("/list", handler) // /api/v2/list
v2.Get("/user", handler) // /api/v2/user
app.Listen(":3000")
}If I request http://127.0.0.1:3000/api/v1/user/1,
Can I get /api/v1/user/:ID at output1?
Reactions are currently unavailable