This commit is contained in:
loveuer
2024-01-11 18:16:41 +08:00
parent b0435ccc35
commit 12ce2a4963
14 changed files with 261 additions and 1145 deletions

View File

@ -2,8 +2,10 @@ package main
import (
"errors"
"fmt"
"log"
"nf"
"time"
)
func main() {
@ -17,5 +19,21 @@ func main() {
return errors.New("nice")
})
v1 := app.Group("/v1")
v1.Get("/hello", func(c *nf.Ctx) error {
return c.JSON(nf.Map{"version": "v1", "date": time.Now()})
})
v1.Get(
"/name",
func(c *nf.Ctx) error {
c.Params["name"] = "zyp"
return c.Next()
},
func(c *nf.Ctx) error {
return c.SendString(fmt.Sprintf("hi, %s", c.Params["name"]))
},
)
log.Fatal(app.Run(":7733"))
}