package main import ( "flag" "log" "mchess_server/api/handler" "github.com/gin-gonic/gin" ) var cert_path = "/etc/letsencrypt/live/chess.sw-gross.de/" var cert_file = cert_path + "fullchain.pem" var key_file = cert_path + "privkey.pem" func main() { var debugMode bool debugModeLong := flag.Bool("debug", false, "activates debug mode") debugModeShort := flag.Bool("d", false, "activates debug mode") flag.Parse() if *debugModeShort || *debugModeLong { debugMode = true } router := gin.Default() router.GET("/api/hostPrivate", handler.HostGameHandler) router.POST("/api/joinPrivate", handler.JoinPrivateGame) router.GET("/api/ws", handler.RegisterWebSocketConnection) router.GET("/api/getLobbyForPassphrase/:phrase", handler.GetLobbyForPassphraseHandler) router.GET("/api/registerWsForGame/:id", handler.ConnectWsForGame) router.POST("/api/joinGame/:id", handler.JoinGameHandler) if debugMode { log.Println("Starting service WITHOUT TLS") log.Fatal(router.Run(":8080")) } else { gin.SetMode(gin.ReleaseMode) log.Println("Starting in release mode") log.Println("Starting service with TLS") log.Fatal(router.RunTLS("chess.sw-gross.de:9999", cert_file, key_file)) } }