-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (35 loc) · 1.03 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
package main
import (
"log"
"github.com/gin-gonic/gin"
"github.com/spf13/pflag"
)
const apiPath = "/api/v1"
func main() {
configfile := pflag.StringP("config", "c", "/tmp/checkup.config", "Configuration file")
httpService := pflag.String("http", ":8801", "HTTP service address")
pflag.Parse()
if err := loadCheckupConfiguration(*configfile); err != nil {
log.Fatalf("ERROR: %v\n", err)
}
initializeOutput()
// Load data
if err := loadInitialData(); err != nil {
log.Fatalf("ERROR: %v\n", err)
}
router := gin.Default()
// Routes
//router.POST(apiPath + "/:a/device", apiAB)
router.GET(apiPath+"/check", apiCheck)
router.GET(apiPath+"/checkup", apiCheckup)
router.GET(apiPath+"/status", apiStatus)
router.GET(apiPath+"/status/:site", apiStatusSite)
router.GET(apiPath+"/timeline", apiTimeline)
router.GET(apiPath+"/timeline/:site", apiTimeline)
router.GET(apiPath+"/stats", apiStats)
router.GET(apiPath+"/stats/:site", apiStats)
// Periodic update
startUpdateTimer()
// Let's go!
router.Run(*httpService)
}