Skip to content
Snippets Groups Projects
Commit e70dda2b authored by gbe's avatar gbe
Browse files

Add flags for db and listening address

parent b3bdc01a
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ package main ...@@ -2,6 +2,7 @@ package main
import ( import (
"embed" "embed"
"flag"
"log" "log"
"net/http" "net/http"
...@@ -36,7 +37,11 @@ func logRequest(r *http.Request) { ...@@ -36,7 +37,11 @@ func logRequest(r *http.Request) {
} }
func main() { func main() {
db, err := bolt.Open("vino.db", 0644, nil) dbPath := flag.String("db", "vino.db", "Path to database file")
listenAddr := flag.String("listen", "127.0.0.1:7878", "Listening address")
flag.Parse()
db, err := bolt.Open(*dbPath, 0644, nil)
if err != nil { if err != nil {
log.Fatalln("can't open DB:", err) log.Fatalln("can't open DB:", err)
} }
...@@ -65,11 +70,9 @@ func main() { ...@@ -65,11 +70,9 @@ func main() {
http.HandleFunc("/user/", auth.Require(http.HandlerFunc(handler.user), ap)) http.HandleFunc("/user/", auth.Require(http.HandlerFunc(handler.user), ap))
http.HandleFunc("/", auth.Require(http.HandlerFunc(handler.index), ap)) http.HandleFunc("/", auth.Require(http.HandlerFunc(handler.index), ap))
const listenAddr = ":7878" log.Printf("here we go, listening on http://%s", *listenAddr)
log.Printf("here we go, listening on http://%s", listenAddr)
err = http.ListenAndServe(listenAddr, nil) err = http.ListenAndServe(*listenAddr, nil)
if err != nil { if err != nil {
log.Fatalln("http handler failed:", err) log.Fatalln("http handler failed:", err)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment