go-pingbot/website/server.go

35 lines
651 B
Go
Raw Normal View History

2021-07-11 21:19:37 +00:00
package website
import (
2021-07-29 18:51:15 +00:00
"fmt"
"os"
2021-07-11 21:19:37 +00:00
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"gitlab.com/gaming0skar123/go/pingbot/common"
2021-07-11 21:19:37 +00:00
"gitlab.com/gaming0skar123/go/pingbot/config"
"gitlab.com/gaming0skar123/go/pingbot/website/routes"
"gitlab.com/gaming0skar123/go/pingbot/website/routes/api"
)
var router *gin.Engine
func Server() {
// Disable GIN Debug
gin.SetMode(gin.ReleaseMode)
router = gin.New()
// Allows all origins
router.Use(cors.Default())
router.GET("/", routes.Index)
api.ApplyRoutes(router)
2021-07-29 18:51:15 +00:00
err := router.Run(fmt.Sprint(":", config.Toml.HTTP.Port))
if common.CheckErr(err, "gin start") {
os.Exit(1)
2021-07-11 21:19:37 +00:00
}
}