You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
704 B

package endpoint
import (
"github.com/arnaucube/gogame/config"
"github.com/arnaucube/gogame/database"
"github.com/arnaucube/gogame/services/usersrv"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
var serverConfig config.Config
var db *database.Db
var userservice *usersrv.Service
func newApiService() *gin.Engine {
api := gin.Default()
api.Use(cors.Default())
api.GET("/", handleMain)
api.GET("/info", handleInfo)
api.POST("/register", handleRegister)
api.POST("/login", handleLogin)
return api
}
func Serve(cnfg config.Config, _db *database.Db, _userservice *usersrv.Service) *gin.Engine {
serverConfig = cnfg
db = _db
userservice = _userservice
return newApiService()
}