fix: middleware not work
This commit is contained in:
@ -6,12 +6,15 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := nf.New()
|
||||
app := nf.New(nf.Config{DisableLogger: false})
|
||||
|
||||
app.Use(ml())
|
||||
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"))
|
||||
}
|
||||
@ -19,6 +22,9 @@ func main() {
|
||||
func ml() nf.HandlerFunc {
|
||||
return func(c *nf.Ctx) error {
|
||||
log.Printf("[ML] [%s] - [%s]", c.Method, c.Path())
|
||||
return c.Next()
|
||||
index := []byte(`<h1>my not found</h1>`)
|
||||
c.Set("Content-Type", "text/html")
|
||||
_, err := c.Write(index)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user