4

I have a gofiber routing like this

app.Use(func(c *fiber.Ctx) error {

  fmt.Println(c.Path()) <--- want this to get the original path name `/user/:id`

  return c.Next()
})
    
app.Get("/user/:id", func(c *fiber.Ctx) error {
    return c.SendString("Hello World")
})

When I call /user/1 the fmt print /user/1

but I want the fmt to print /user/:name how can I implement it

samithiwat
  • 49
  • 3
  • If nothing helps, you can create a method like `func CreateMiddleware(endpoint string, handler func(*fiber.Ctx) error) func(ctx *fiber.Ctx)`, so you can pass the endpoint at creation and have it available in the middleware function. But tbh. it feels a bit as if you're approaching it the wrong way. What do you need that "original" path name for? – NotX Sep 16 '22 at 11:09
  • @Notx Thank for your answer. I have the auth middleware and the exclude path list, I want the original path for checking is this path is exclude from the middleware – samithiwat Sep 16 '22 at 17:58

1 Answers1

0

Try to use c.OriginalURL() instead of c.Path()