Exemple #1
0
func main() {
	log.UseStderr(true)
	log.SetV(9)
	flag.Parse()
	m := martini.New()
	m.Use(martini.Logger())
	m.Use(martini.Recovery())
	r := martini.NewRouter()

	tde := kv.NewTiedotEngine("./tiedotdb", []string{"short.url", "short.counter"}, kv.KeepIfExist)
	tde.AddIndex("short.url", kv.Path{"Short"})
	tde.AddIndex("short.counter", kv.Path{"Count"})

	if *useShort {
		log.Info("Starting LWS.short")
		s := short.NewShortener(tde)
		r.Any("/s", stripper("/s"), s.ServeHTTP)
		r.Any("/s/.*", stripper("/s"), s.ServeHTTP)
	}

	m.Action(r.Handle)
	http.ListenAndServe(*port, m)
}
Exemple #2
0
func getEngine() *kv.TiedotEngine {
	return kv.NewTiedotEngine("./tmp", []string{"fake"}, kv.DropIfExist)
}