/
main.go
39 lines (31 loc) · 1020 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
package main
import (
"csgo-2d-demo-player/conf"
"csgo-2d-demo-player/pkg/log"
"csgo-2d-demo-player/pkg/provider/faceit"
"csgo-2d-demo-player/pkg/provider/steam"
"fmt"
"net/http"
"github.com/alexflint/go-arg"
"go.uber.org/zap"
)
var config *conf.Conf
var faceitClient *faceit.FaceitClient
var steamClient *steam.SteamClient
func main() {
config = &conf.Conf{}
arg.MustParse(config)
log.Init(config)
defer log.Close()
log.L().Debug("using config", zap.Any("config", config))
server()
}
func server() {
mux := http.NewServeMux()
mux.Handle("/assets/", http.StripPrefix("/assets", http.FileServer(http.Dir("./assets"))))
mux.Handle("/", http.FileServer(http.Dir("web/index/build")))
log.L().Info("HTTP server listening on ...", zap.String("listen", config.Listen), zap.Int("port", config.Port))
// log.Println("Listening on ", config.Port, " ...")
listenErr := http.ListenAndServe(fmt.Sprintf("%s:%d", config.Listen, config.Port), mux)
log.L().Fatal("failed to listen", zap.Error(listenErr))
}