nf/xtest/basic/main.go

29 lines
448 B
Go
Raw Permalink Normal View History

2024-01-12 19:18:33 +08:00
package main
import (
"github.com/loveuer/nf"
"log"
)
func main() {
2024-04-10 11:24:17 +08:00
app := nf.New(nf.Config{})
app.Get("/ok", func(c *nf.Ctx) error {
return c.SendStatus(200)
})
2024-01-12 19:18:33 +08:00
2024-02-20 15:34:00 +08:00
api := app.Group("/api")
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)
2024-02-01 18:06:07 +08:00
})
log.Fatal(app.Run(":80"))
2024-01-12 19:18:33 +08:00
}