-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRotaenoAPIServer.go
65 lines (54 loc) · 1.8 KB
/
RotaenoAPIServer.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
57
58
59
60
61
62
63
64
65
package main
import (
"fmt"
"net/http"
"os"
"path/filepath"
"rotaenoAPIServer/APIHandlers"
"rotaenoAPIServer/Utils"
)
const (
dbName = "rotaenoAPIServer"
tableName = "allowedObjectIDs"
)
func main() {
var config Utils.Config
err := Utils.InitConfig()
if err != nil {
fmt.Println(err)
return
}
config, err = Utils.GetConfig()
if err != nil {
fmt.Println(err)
return
}
// Init Directory
executablePath, _ := os.Executable()
rootPath := filepath.Dir(executablePath)
dataPath := filepath.Join(rootPath, config.FilePath)
if _, err := os.Stat(dataPath); os.IsNotExist(err) {
_ = os.MkdirAll(dataPath, 0755)
}
// Init API
apiVersion := config.APIVersion
handleFunctions(apiVersion)
// Init Http Server
err = http.ListenAndServe(":"+config.ServerPort, nil)
if err != nil {
fmt.Println("Failed to open server: ", err)
return
}
}
func handleFunctions(apiVersion string) {
http.HandleFunc("/"+apiVersion+"/users", APIHandlers.GetUsersInformationHandler)
http.HandleFunc("/"+apiVersion+"/users/", APIHandlers.GetUsersInformationHandler)
http.HandleFunc("/"+apiVersion+"/call/GetPurchasedItemData", APIHandlers.GetPurchasedItemDataApiHandler)
http.HandleFunc("/"+apiVersion+"/call/CheckForUpdates", APIHandlers.CheckForUpdatesApiHandler)
http.HandleFunc("/"+apiVersion+"/classes/CloudSave", APIHandlers.CloudSaveApiHandler)
http.HandleFunc("/"+apiVersion+"/classes/CloudSave/", APIHandlers.CloudSaveApiHandler)
http.HandleFunc("/"+apiVersion+"/call/CheckSafeText", APIHandlers.CheckSafeTextApiHandler)
http.HandleFunc("/"+apiVersion+"/call/GetAllFolloweeSocialData", APIHandlers.CopyAndResendApiHandler)
http.HandleFunc("/"+apiVersion+"/call/IncreaseFriendCap", APIHandlers.CopyAndResendApiHandler)
http.HandleFunc("/"+apiVersion+"/call/FollowPlayer", APIHandlers.CopyAndResendApiHandler)
}