Esempio n. 1
0
func main() {
	logger := log.New(os.Stdout, "runserver ", log.LstdFlags)

	address := "127.0.0.1:3003"

	db, err := modena.DBFromEnv(logger)
	if err != nil {
		logger.Fatalf("Cannot find sqlite3 database: %s", err)
	}

	//run statement after defer when stack frame gets popped
	defer db.Close()

	//we init gorp with Sqlite dialect
	dbmap := &gorp.DbMap{Db: db, Dialect: gorp.SqliteDialect{}}

	//create the resource
	q := modena.NewQuoteResource(dbmap, logger)
	rest.Resource("/quote/", q)

	//static content :  /static->modena/web
	modenaStaticContent("/static/", "web", logger)
	//static content :  /dart->modena/dart
	modenaStaticContent("/dart/", "dart", logger)

	//function should never return... this is the standard HTTP listener
	if err = http.ListenAndServe(address, logHTTP(http.DefaultServeMux, logger)); err != nil {
		logger.Fatalf("ListenAndServe failed! %s", err)
	}
}
Esempio n. 2
0
func main() {
	log.Println("Starting Server")
	address := "127.0.0.1:3000"

	var wd = new(Weekdays)
	wd.wd = wdmap
	rest.Resource("/wd/", wd)

	if err := http.ListenAndServe(address, nil); err != nil {
		log.Fatalln(err)
	}
}