-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
36 lines (32 loc) · 863 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
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"github.com/google/go-cmp/cmp"
"github.com/ragadeeshu/alterna-freshness-league/datahandling"
"github.com/ragadeeshu/alterna-freshness-league/web"
)
func main() {
var league datahandling.League
port := flag.String("port", "8080", "Port to bind to")
proxy := flag.Bool("proxy", false, "Start in proxy mode")
flag.Var(&league, "league", "Contestants json string, tries to read 'contestants.json' file if not set")
flag.Parse()
if cmp.Equal(league, datahandling.League{}) {
byteValue, err := ioutil.ReadFile("contestants.json")
if err != nil {
return
}
err = json.Unmarshal(byteValue, &league)
if err != nil {
panic(err)
}
}
cache := datahandling.NewCache()
if *proxy {
web.StartProxyServer(cache, league, *port)
} else {
web.StartWebServer(cache, league, *port)
}
}