package main import ( "flag" "fmt" "github.com/jmoiron/sqlx" "github.com/kelseyhightower/envconfig" _ "github.com/lib/pq" "log" "net/http" ) var verbose = flag.Bool("verbose", false, "increase logging verbosity") var db *sqlx.DB func main() { flag.Parse() log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile) config := NewConfig() err := envconfig.Process("ITSLOG", config) if err != nil { log.Fatal(err) } if err := config.validate(); err != nil { log.Fatal(err) } log.Printf("config: %#v", config) dbSetup(config) http.Handle("/api/v0/info/", JsonHandler(apiInfo)) http.Handle("/api/v0/put/", JsonHandler(put)) err = http.ListenAndServe(fmt.Sprintf(":%d", config.Port), nil) if err != nil { log.Fatal(err) } }