payment-poc/api/server.go

26 lines
433 B
Go
Raw Permalink Normal View History

2024-04-01 18:29:24 +00:00
package api
import (
"github.com/gin-gonic/gin"
"github.com/jmoiron/sqlx"
)
func SetupServer(db *sqlx.DB) *gin.Engine {
server := createServer()
LoadTemplates(server)
RegisterRoutes(server, db)
return server
}
func createServer() *gin.Engine {
server := gin.New()
server.NoRoute(NoRoute())
server.NoMethod(NoMethod())
server.Use(gin.Recovery())
auth := Auth()
if auth != nil {
server.Use(Auth())
}
return server
}