-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
51 lines (38 loc) · 1.39 KB
/
server.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
package main
import (
"fmt"
"net/http"
"os"
"github.com/EMOtions/cache"
"github.com/EMOtions/handlers"
)
func main() {
fmt.Println("Starting EMOtions...")
//checking if port is local or not
PORT := os.Args[1]
if PORT == "local" {
PORT = "8001"
}
cache.SetupEmoURL(PORT)
cache.DecryptKey()
cache.Populate()
cache.Schedule()
//available API calls
http.HandleFunc("/buttons", handlers.ButtonsHandler)
http.HandleFunc("/tables", handlers.TablesListHandler)
http.HandleFunc("/reviews", handlers.ReviewsHandler)
http.HandleFunc("/deltaconstructor", handlers.DeltaConstructorHandler)
http.HandleFunc("/deltatest", handlers.DeltaTestHandler)
http.HandleFunc("/searchcoordinate", handlers.SearchCoordinateHandler)
http.HandleFunc("/subscription", handlers.SubscriptionHandler)
http.HandleFunc("/queueinfo", handlers.QueueHandler)
http.HandleFunc("/queuemessage", handlers.QueueMessageHandler)
//serving pages, based on structure of index.html files in their respective folders
//in the public folder
http.Handle("/", http.FileServer(http.Dir("./public")))
http.Handle("/databus", http.StripPrefix("/databus", http.FileServer(http.Dir("./public/databus"))))
http.Handle("/queue", http.StripPrefix("/queue", http.FileServer(http.Dir("./public/queue"))))
//program should pause after this line
http.ListenAndServe(":" + PORT, nil)
fmt.Println("Server ListenAndServe ended unexpectedly")
}