From 26cd833d20d8b29586867039b76b978ef1f1c8b0 Mon Sep 17 00:00:00 2001 From: Samuel Berthe Date: Tue, 24 Oct 2023 11:33:08 +0200 Subject: [PATCH] doc --- README.md | 7 +++++++ example/example.go | 1 + 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index ac4b243..f63c039 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ router := gin.New() // Add the sloggin middleware to all routes. // The middleware will log all requests attributes. router.Use(sloggin.New(logger)) +router.Use(gin.Recovery()) // Example pong request. router.GET("/pong", func(c *gin.Context) { @@ -113,6 +114,7 @@ router.Use( sloggin.IgnoreStatus(401, 404), ), ) +router.Use(gin.Recovery()) ``` Available filters: @@ -159,6 +161,7 @@ router := gin.New() // Add the sloggin middleware to all routes. // The middleware will log all requests attributes. router.Use(sloggin.New(logger)) +router.Use(gin.Recovery()) // Example pong request. router.GET("/pong", func(c *gin.Context) { @@ -181,6 +184,7 @@ router := gin.New() // Add the sloggin middleware to all routes. // The middleware will log all requests attributes under a "http" group. router.Use(sloggin.New(logger.WithGroup("http"))) +router.Use(gin.Recovery()) // Example pong request. router.GET("/pong", func(c *gin.Context) { @@ -199,6 +203,7 @@ router.Run(":1234") logger := slog.New(slog.NewTextHandler(os.Stdout, nil)) router := gin.New() +router.Use(gin.Recovery()) // Example pong request. // Add the sloggin middleware to a single routes. @@ -226,6 +231,7 @@ router := gin.New() // Add the sloggin middleware to all routes. // The middleware will log all requests attributes. router.Use(sloggin.New(logger)) +router.Use(gin.Recovery()) // Example pong request. router.GET("/pong", func(c *gin.Context) { @@ -250,6 +256,7 @@ router := gin.New() // Add the sloggin middleware to all routes. // The middleware will log all requests attributes. router.Use(sloggin.New(logger)) +router.Use(gin.Recovery()) // Example pong request. router.GET("/pong", func(c *gin.Context) { diff --git a/example/example.go b/example/example.go index 5f2724f..be78877 100644 --- a/example/example.go +++ b/example/example.go @@ -35,6 +35,7 @@ func main() { router.Use(sloggin.New(logger)) // config := sloggin.Config{WithRequestBody: true, WithResponseBody: true, WithRequestHeader: true, WithResponseHeader: true} // router.Use(sloggin.NewWithConfig(logger, config)) + router.Use(gin.Recovery()) // Example pong request. router.GET("/pong", func(c *gin.Context) {