-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (36 loc) · 966 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"os"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"github.com/srjnm/csgo-weakspots/apis"
"github.com/srjnm/csgo-weakspots/controllers"
"github.com/srjnm/csgo-weakspots/services"
)
func main() {
fmt.Println("Server startup in progress..")
var port string
err := godotenv.Load()
if err != nil {
port = os.Getenv("PORT")
}
if port == "" {
port = "8080"
}
gin.SetMode(gin.ReleaseMode)
demoService := services.NewDemoParseService(18)
demoController := controllers.NewDemoController(demoService)
demoAPI := apis.NewDemoAPI(demoController)
server := gin.Default()
server.LoadHTMLGlob("html/*.html")
server.Static("/assets", "./html/assets")
server.StaticFile("/favicon.png", "assets/favicon.png")
server.NoRoute(demoAPI.NoRouteHandler)
// Front-End
server.GET("/", demoAPI.WeakSpotGetHandler)
// Back-End
server.POST("/spotmap", demoAPI.SpotMapPostHandler)
// Serve
server.Run(":" + port)
}