26 lines
433 B
Go
26 lines
433 B
Go
|
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
|
||
|
}
|