-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (29 loc) · 786 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
package main
import (
"fmt"
"net/http"
"os"
"github.com/matthiashermsen/dewit/api"
"github.com/matthiashermsen/dewit/app"
"github.com/matthiashermsen/dewit/cfg"
"github.com/matthiashermsen/dewit/log"
"github.com/matthiashermsen/dewit/store"
)
func main() {
logLevel, err := cfg.GetLogLevel()
if err != nil {
panic(err)
}
logger := log.New(logLevel)
inMemoryStore := store.NewInMemoryStore(logger)
mux := api.New(app.Version, inMemoryStore, logger)
port := cfg.GetPort()
address := fmt.Sprintf(":%s", port)
logger.Info(fmt.Sprintf("Running on version %s", app.Version))
logger.Info(fmt.Sprintf("Server listening on port %s", port))
err = http.ListenAndServe(address, mux)
if err != nil {
log.Error(logger, "Could not serve API", err)
os.Exit(1)
}
}