-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.go
56 lines (43 loc) · 1.35 KB
/
api.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
package main
import (
"encoding/json"
"github.com/real-time-footfall-analysis/rtfa-backend/emergency"
"github.com/real-time-footfall-analysis/rtfa-backend/notifications"
"net/http"
"github.com/gorilla/mux"
"github.com/real-time-footfall-analysis/rtfa-backend/eventlivedata"
"github.com/real-time-footfall-analysis/rtfa-backend/eventstaticdata"
"github.com/real-time-footfall-analysis/rtfa-backend/locationupdate"
"github.com/real-time-footfall-analysis/rtfa-backend/readanalytics"
"github.com/real-time-footfall-analysis/rtfa-backend/utils"
)
type App struct {
Router *mux.Router
}
func initialize(a *App) {
a.Router = mux.NewRouter()
initializeRoutes(a)
}
func initializeRoutes(a *App) {
a.Router.HandleFunc("/", standardHandler)
a.Router.HandleFunc("/api/health", healthHandler).Methods("GET")
a.Router.Methods("OPTIONS").HandlerFunc(preflightHandler)
eventstaticdata.Init(a.Router)
locationupdate.Init(a.Router)
eventlivedata.Init(a.Router)
readanalytics.Init(a.Router)
emergency.Init(a.Router)
notifications.Init(a.Router)
}
func preflightHandler(w http.ResponseWriter, r *http.Request) {
utils.SetAccessControlHeaders(w)
}
func standardHandler(w http.ResponseWriter, _ *http.Request) {
_ = json.NewEncoder(w).Encode(TestMessage{
Message: "Hello, World!",
})
return
}
func healthHandler(_ http.ResponseWriter, _ *http.Request) {
return
}