feat: api stdout logger

This commit is contained in:
loveuer
2024-01-14 19:10:05 +08:00
parent 8f4132f131
commit 7057e232e6
4 changed files with 79 additions and 12 deletions

View File

@ -4,6 +4,7 @@ import (
"github.com/loveuer/nf"
"log"
"net"
"time"
)
func main() {
@ -13,6 +14,11 @@ func main() {
name := c.Param("name")
return c.JSON(nf.Map{"status": 200, "data": "hello, " + name})
})
app.Patch("/world", func(c *nf.Ctx) error {
time.Sleep(5 * time.Second)
c.Status(404)
return c.JSON(nf.Map{"method": c.Method, "status": c.StatusCode})
})
ln, _ := net.Listen("tcp", ":80")
log.Fatal(app.RunListener(ln))