aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.go6
-rw-r--r--store.go4
2 files changed, 7 insertions, 3 deletions
diff --git a/main.go b/main.go
index 998791a..a8afe72 100644
--- a/main.go
+++ b/main.go
@@ -7,6 +7,7 @@ import (
"html/template"
"log"
"net/http"
+ "os"
"strconv"
"time"
)
@@ -67,7 +68,10 @@ func (app *App) loginHandler(w http.ResponseWriter, r *http.Request) {
func main() {
//log.SetFlags(log.LstdFlags)
- store := NewPgStore()
+ if len(os.Args) == 1 {
+ log.Fatalf("Usage: %s <connect-string>\n", os.Args[0])
+ }
+ store := NewPgStore(os.Args[1])
template := template.Must(template.New("").ParseGlob("templates/*.tmpl"))
app := &App{store, template}
http.HandleFunc("/validate", app.validateHandler)
diff --git a/store.go b/store.go
index 1f0ca76..1c8348f 100644
--- a/store.go
+++ b/store.go
@@ -28,8 +28,8 @@ type PgStore struct {
sessionCache map[string]*Session
}
-func NewPgStore() *PgStore {
- db, err := sql.Open("postgres", "postgres://auth_master:pass@localhost/authdb")
+func NewPgStore(database string) *PgStore {
+ db, err := sql.Open("postgres", database)
if err != nil {
log.Panic(err)
}