refactory: rebuild route tree

This commit is contained in:
loveuer
2024-02-20 15:34:00 +08:00
parent 137d4ee5c8
commit 039f4cf8c0
19 changed files with 1738 additions and 324 deletions

View File

@ -11,19 +11,17 @@ func main() {
app.Get("/hello", func(c *nf.Ctx) error {
return c.SendString("world")
})
app.Get("/panic", func(c *nf.Ctx) error {
panic("panic")
})
app.Use(ml())
log.Fatal(app.Run(":7777"))
log.Fatal(app.Run(":80"))
}
func ml() nf.HandlerFunc {
return func(c *nf.Ctx) error {
log.Printf("[ML] [%s] - [%s]", c.Method, c.Path())
index := []byte(`<h1>my not found</h1>`)
c.Set("Content-Type", "text/html")
c.Status(403)
_, err := c.Write(index)
return err
}