update: hide Param, add SetParam(can't cover value)

This commit is contained in:
loveuer
2024-04-10 18:03:38 +08:00
parent 9530fa863f
commit 56fa3815cb
3 changed files with 18 additions and 5 deletions

View File

@ -13,8 +13,15 @@ func main() {
})
api := app.Group("/api")
api.Get("/1", func(c *nf.Ctx) error {
return c.SendString("nice")
api.Use(func(c *nf.Ctx) error {
c.SetParam("age", "18")
return c.Next()
})
api.Get("/:name", func(c *nf.Ctx) error {
name := c.Param("name")
age := c.Param("age")
return c.SendString(name + "@" + age)
})
log.Fatal(app.Run(":80"))