Exemplo n.º 1
0
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))
	}
}
Exemplo n.º 2
0
// 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)
}
Exemplo n.º 3
0
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)
}