I have a bunch of routes and start off gin with gin.Default()
(enabling logging and recovery for all routes by default). But there is one route (i.e. /health
) that gets pinged every 5 seconds. What's a straightforward way to disable request logging for that one route without changing much of the code?
func main() {
// gin is initialized upstream in our internal framework
// so I can't change this line easily.
router := gin.Default()
router.GET("/someGet", getting)
router.POST("/somePost", posting)
router.PUT("/somePut", putting)
router.DELETE("/someDelete", deleting)
// ... and more
// Disable request logging for only this route.
// Note: I'm hoping that there's some parameter I can pass in here to do that
route.GET("/health", health)
router.Run()
}