This repository has been archived by the owner on Jun 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
56 lines (45 loc) · 2.31 KB
/
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
49
50
51
52
53
54
55
56
//Represents the main package of this project and the file to be "executed" at
//first level.
package main
import (
"net/http"
"sanino/gamemate/configurations"
"sanino/gamemate/constants"
"sanino/gamemate/controllers/developer"
"sanino/gamemate/controllers/game_owner"
"sanino/gamemate/controllers/user/login_controller"
"sanino/gamemate/controllers/user/out_game_controller"
"sanino/gamemate/game_server_configurations"
"github.com/labstack/echo"
)
type dummy struct {
Message string `json:"message" xml:"message" form:"message"`
}
//Main function of the server : here there are the allowed messages of connections
//and their behaviour.
func main() {
e := configurations.InitServer()
//Links with redis to permit cache usage.
configurations.InitCache()
configurations.InitArchives()
//defer redisPool.Close()
e.POST("/", func(c echo.Context) error { return c.JSON(http.StatusOK, &dummy{Message: "Up and running..."}) })
e.POST(constants.AUTH_PATH, loginController.HandleAuth)
e.POST(constants.USER_REGISTRATION_PATH, loginController.HandleRegistration)
e.POST(constants.USER_ALL_GAME_LIST_PATH, outGameController.HandleAllGamesForUser)
e.POST(constants.USER_ENABLED_GAME_LIST_PATH, outGameController.HandleMyEnabledGamesForUser)
e.POST(constants.DEVELOPER_AUTH_PATH, developerController.HandleLogin)
e.POST(constants.DEVELOPER_REGISTRATION_PATH, developerController.HandleRegistration)
e.POST(constants.DEVELOPER_TOKEN_LIST_PATH, developerController.HandleAllTokensForDeveloper)
e.POST(constants.DEVELOPER_ADD_API_TOKEN_PATH, developerController.HandleAddAPI_Token)
e.POST(constants.DEVELOPER_DROP_API_TOKEN_PATH, developerController.HandleDropAPI_Token)
e.POST(constants.GAME_OWNER_AUTH_PATH, gameOwnerController.HandleLogin)
e.POST(constants.GAME_OWNER_REGISTRATION_PATH, gameOwnerController.HandleRegistration)
e.POST(constants.GAME_OWNER_ADD_GAME_PATH, gameOwnerController.HandleAddGame)
e.POST(constants.GAME_OWNER_REMOVE_GAME_PATH, gameOwnerController.HandleRemoveGame)
e.POST(constants.GAME_ENABLE_DISABLE_PATH, gameOwnerController.HandleGameAction)
e.POST(constants.GAME_OWNER_GAME_LIST_PATH, gameOwnerController.HandleShowMyGames)
gameServerConfigurations.InitGameServer(e)
e.Logger.Print(e.Start(":8080"))
//e.Logger.Print(e.StartTLS(":8080", "/opt/GameMate/certs/cert.pem", "/opt/GameMate/certs/key.pem"))
}