Hi, I am searching if I can exclude an entire request method from logger..

I'm using skipPaths to exclude some endpoints to log, but I would like to discard, for example, all OPTIONS method before each POST/GET request.. Is any way to do this actually? Here is how I have configured my logger..

    r := gin.New()
    r.Use(gin.Recovery())
    r.Use(gin.LoggerWithConfig(gin.LoggerConfig{
        SkipPaths: []string{"/health", "/api/index.html"},
    },
    ))

Many thanks!

Comment From: appleboy

func main() {
    r := gin.New()
    r.Use(gin.Recovery())
    r.Use(gin.LoggerWithConfig(gin.LoggerConfig{
        Skip: func(c *gin.Context) bool {
            if c.Request.Method == "OPTIONS" {
                return true
            }
            return false
        },
    },
    ))

    // Listen and Server in 0.0.0.0:8080
    if err := r.Run(":8080"); err != nil {
    }
}

gin version: v1.10.0

Comment From: marticrespi

Cool! Many thanks!