func main() { // parse command line flags flag.StringVar(&port, "port", ":8080", "") flag.StringVar(&driver, "driver", "sqlite3", "") flag.StringVar(&datasource, "datasource", "mediaman.sqlite", "") flag.StringVar(&sslcert, "sslcert", "", "") flag.StringVar(&sslkey, "sslkey", "", "") flag.Parse() // validate the TLS arguments checkTLSFlags() // setup database and handlers if err := database.Init(driver, datasource); err != nil { log.Fatal("Can't initialize database: ", err) } setupHandlers() // debug log.Printf("starting mediaman version %s on port %s\n", version, port) // start webserver using HTTPS or HTTP if sslcert != "" && sslkey != "" { panic(http.ListenAndServeTLS(port, sslcert, sslkey, nil)) } else { panic(http.ListenAndServe(port, nil)) } }
// Before func (s *SeasonTestSuite) SetUpTest(c *C) { // Initialize the test database database.Init("sqlite3", "/tmp/mediaman_test.sqlite") // Create the handlers m := pat.New() AddHandlers(m, "/api") s.server = httptest.NewServer(m) }
func createTestServer() *httptest.Server { // Initialize the test database database.Init("sqlite3", TEST_DATABASE) // Create the handlers m := pat.New() AddHandlers(m, "/api") return httptest.NewServer(m) }