예제 #1
0
// Attach handlers that provide the Database API
func storeHandle(factory chunks.Factory, hndlr datas.Handler) httprouter.Handle {
	return func(w http.ResponseWriter, req *http.Request, params httprouter.Params) {
		cs := factory.CreateStore(params.ByName(dbParam))
		defer cs.Close()
		hndlr(w, req, params, cs)
	}
}
예제 #2
0
파일: main.go 프로젝트: willhite/noms-old
func main() {
	chunks.RegisterLevelDBFlags()
	dynFlags := chunks.DynamoFlags("")

	flag.Usage = usage
	flag.Parse()

	if *portFlag == 0 || *authKeyFlag == "" {
		usage()
		return
	}

	var factory chunks.Factory
	if factory = dynFlags.CreateFactory(); factory != nil {
		fmt.Printf("Using dynamo ...\n")
	} else if *ldbDir != "" {
		factory = chunks.NewLevelDBStoreFactoryUseFlags(*ldbDir)
		fmt.Printf("Using leveldb ...\n")
	} else {
		factory = chunks.NewMemoryStoreFactory()
		fmt.Printf("Using mem ...\n")
	}
	defer factory.Shutter()

	startWebServer(factory, *authKeyFlag)
}