github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/api/router.go (about)

     1  package api
     2  
     3  import (
     4  	"github.com/gin-gonic/gin"
     5  	"github.com/mundipagg/boleto-api/healthcheck"
     6  )
     7  
     8  func Base(router *gin.Engine) {
     9  	router.StaticFile("/favicon.ico", "./boleto/favicon.ico")
    10  	router.GET("/boleto", getBoletoLogger, getBoleto)
    11  	router.GET("/boleto/memory-check/:unit", memory)
    12  	router.GET("/boleto/memory-check/", memory)
    13  	router.GET("/boleto/confirmation", confirmation)
    14  	router.POST("/boleto/confirmation", confirmation)
    15  	router.GET("/healthcheck", healthcheck.ExecuteOnAPI)
    16  	router.GET("/ping", healthcheck.Ping)
    17  }
    18  
    19  //V1 configura as rotas da v1
    20  func V1(router *gin.Engine) {
    21  	v1 := router.Group("v1")
    22  	v1.Use(timingMetrics())
    23  	v1.Use(returnHeaders())
    24  	v1.POST("/boleto/register", authentication, parseBoleto, validateRegisterV1, registerBoletoLogger, errorResponseToClient, panicRecoveryHandler, registerBoleto)
    25  	v1.GET("/boleto/:id", getBoletoByID)
    26  }
    27  
    28  //V2 configura as rotas da v2
    29  func V2(router *gin.Engine) {
    30  	v2 := router.Group("v2")
    31  	v2.Use(timingMetrics())
    32  	v2.Use(returnHeaders())
    33  	v2.POST("/boleto/register", authentication, parseBoleto, validateRegisterV2, registerBoletoLogger, handleErrors, panicRecoveryHandler, registerBoleto)
    34  }