nf/xtest/basic/main.go

20 lines
311 B
Go
Raw Permalink Normal View History

2024-01-12 19:18:33 +08:00
package main
import (
"github.com/loveuer/nf"
"log"
2024-01-13 17:45:44 +08:00
"net"
2024-01-12 19:18:33 +08:00
)
func main() {
app := nf.New()
app.Get("/hello/:name", func(c *nf.Ctx) error {
name := c.Param("name")
return c.JSON(nf.Map{"status": 200, "data": "hello, " + name})
})
2024-01-13 17:45:44 +08:00
ln, _ := net.Listen("tcp", ":80")
log.Fatal(app.RunListener(ln))
2024-01-12 19:18:33 +08:00
}