Define format for the log of routes

    1. import (
    2. "log"
    3. "net/http"
    4. "github.com/gin-gonic/gin"
    5. )
    6. func main() {
    7. gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {
    8. log.Printf("endpoint %v %v %v %v\n", httpMethod, absolutePath, handlerName, nuHandlers)
    9. }
    10. r.POST("/foo", func(c *gin.Context) {
    11. c.JSON(http.StatusOK, "foo")
    12. })
    13. c.JSON(http.StatusOK, "bar")
    14. })
    15. r.GET("/status", func(c *gin.Context) {
    16. c.JSON(http.StatusOK, "ok")
    17. })
    18. // Listen and Server in http://0.0.0.0:8080
    19. }