From d91c1313942e417230c0e24dff56e19643e5c404 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 22 Jun 2024 13:41:43 +0200 Subject: [PATCH] Added middleware documentation --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 157ad13..b6930cd 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,17 @@ s.Get("/images/*file", func(ctx web.Context) error { 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") ```