forked from annav1asova/hwproj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
executable file
·37 lines (28 loc) · 791 Bytes
/
main.go
File metadata and controls
executable file
·37 lines (28 loc) · 791 Bytes
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
package main
import (
"flag"
"log"
"net/http"
_"hwproj/memory"
"hwproj/daemon"
)
var assetsPath string
func processFlags() *daemon.Config {
cfg := &daemon.Config{}
flag.StringVar(&cfg.ListenSpec, "listen", "localhost:3001", "HTTP listen spec")
flag.StringVar(&cfg.Db.ConnectString, "db-connect", "host=localhost port=5432 user=postgres dbname=gowebapp sslmode=disable", "DB Connect String")
flag.StringVar(&assetsPath, "assets-path", "assets", "Path to assets dir")
flag.Parse()
return cfg
}
func setupHttpAssets(cfg *daemon.Config) {
log.Printf("Assets served from %q.", assetsPath)
cfg.UI.Assets = http.Dir(assetsPath)
}
func main() {
cfg := processFlags()
setupHttpAssets(cfg)
if err := daemon.Run(cfg); err != nil {
log.Printf("Error in main(): %v", err)
}
}