Added middleware documentation

This commit is contained in:
Eduard Urbach 2024-06-22 13:41:43 +02:00
parent 24b7c6ead7
commit d91c131394
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

View File

@ -34,6 +34,17 @@ s.Get("/images/*file", func(ctx web.Context) error {
return ctx.String(ctx.Request().Param("file")) return ctx.String(ctx.Request().Param("file"))
}) })
// Middleware
s.Use(func(ctx web.Context) error {
start := time.Now()
defer func() {
fmt.Println(ctx.Request().Path(), time.Since(start))
}()
return ctx.Next()
})
s.Run(":8080") s.Run(":8080")
``` ```