This commit is contained in:
parent
90cb4bc674
commit
9761710bd1
|
@ -31,20 +31,21 @@ type Stat struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
var hostPort,baseURL,database string
|
||||
flag.StringVar(&hostPort, "http", ":80", "host and port to listen on")
|
||||
flag.StringVar(&baseURL, "baseurl", "", "baseurl that the server should response with")
|
||||
flag.StringVar(&database, "database", "localhost:9999", "database hostpost")
|
||||
hostPort := flag.String("http", ":80", "host and port to listen on")
|
||||
baseURL := flag.String("baseurl", "", "baseurl that the server should response with")
|
||||
database := flag.String("database", "localhost:9999", "database hostpost")
|
||||
flag.Parse()
|
||||
|
||||
dsn := fmt.Sprintf("postgres://%v:%v@%s/hub?sslmode=disable", "postgres", "simple", database)
|
||||
log.Printf("Using arguments http=%s baseurl=%s database=%s", *hostPort, *baseURL, *database)
|
||||
|
||||
dsn := fmt.Sprintf("postgres://%v:%v@%s/hub?sslmode=disable", "postgres", "simple", *database)
|
||||
store, err := storage.New(dsn)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
handler := &subscriptionHandler{store, baseURL}
|
||||
handler := &subscriptionHandler{store, *baseURL}
|
||||
http.Handle("/", handler)
|
||||
log.Fatal(http.ListenAndServe(hostPort, nil))
|
||||
log.Fatal(http.ListenAndServe(*hostPort, nil))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user