From d954e0fc21fb74962517f3ace941d1ca34978b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?And=C5=BEej=20Maciusovi=C4=8D?= Date: Fri, 19 Jul 2019 10:00:23 +0300 Subject: [PATCH] Update README.md --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7daa979..c29af2f 100644 --- a/README.md +++ b/README.md @@ -40,15 +40,20 @@ import ( "github.com/goroute/route" ) -type hello struct { - Title string +type helloResponse struct { + Title string `json:"title"` } func main() { mux := route.NewServeMux() - mux.GET("/", func (c route.Context) error { - return c.JSON(http.StatusOK, &hello{Title:"Hello, World!"}) + mux.Use(func(c route.Context, next route.HandlerFunc) error { + log.Println("Hello, Middleware!") + return next(c) + }) + + mux.GET("/", func(c route.Context) error { + return c.JSON(http.StatusOK, &helloResponse{Title:"Hello, JSON!"}) }) log.Fatal(http.ListenAndServe(":9000", mux))