-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
56 lines (51 loc) · 934 Bytes
/
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
package main
import (
"encoding/json"
"log"
"math/rand"
"net/http"
"os"
"time"
"github.com/gin-gonic/gin"
"github.com/obfio/px-grubhub-mobile/px"
)
var (
devices = []*px.Device{}
levels = make(map[string]int)
)
func init() {
rand.Seed(time.Now().UnixNano())
b, err := os.ReadFile("devices.json")
if err != nil {
panic(err)
}
err = json.Unmarshal(b, &devices)
if err != nil {
panic(err)
}
b, err = os.ReadFile("levels.json")
if err != nil {
panic(err)
}
err = json.Unmarshal(b, &levels)
if err != nil {
panic(err)
}
}
func main() {
router := gin.New()
router.Use(gin.Recovery())
px := router.Group("px")
px.POST("bake", bake)
s := &http.Server{
Addr: "127.0.0.1:7356",
Handler: router,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
MaxHeaderBytes: 1 << 20,
}
err := s.ListenAndServe()
if err != nil {
log.Fatalf("httpServe: %s", err)
}
}