Skip to content

Commit

Permalink
feat: add example of skipper usage in main.go
Browse files Browse the repository at this point in the history
- Add an example of skipper usage in the main.go file

Signed-off-by: appleboy <[email protected]>
  • Loading branch information
appleboy committed Feb 2, 2024
1 parent 637bb30 commit e6115f7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions _example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ func main() {
c.String(http.StatusOK, "pong "+fmt.Sprint(time.Now().Unix()))
})

// Example of skipper usage
r.GET("/health", logger.SetLogger(
logger.WithSkipper(func(c *gin.Context) bool {
return c.Request.URL.Path == "/health"
}),
), func(c *gin.Context) {
c.String(http.StatusOK, "pong "+fmt.Sprint(time.Now().Unix()))
})

// Listen and Server in 0.0.0.0:8080
if err := r.Run(":8080"); err != nil {
log.Fatal().Msg("can' start server with 8080 port")
Expand Down

0 comments on commit e6115f7

Please sign in to comment.