func TestRedisDo(t *testing.T) { // test database configuration pwd := "" dbPort := 13 // establish a connection with the database Db := new(database.RedisDo) Db.Init(pwd, dbPort) defer Db.Close() testRunnerRedisDo(t, Db) }
func StartServer() { log.Println("Starting API server now.") // configurate the database connection Db := new(database.RedisDo) Db.Init("", 10) // set up a nice glas of martini m := martini.Classic() // http://localhost:3000 m.Get("/", func() string { return `{"result":"Hello world!"}` }) // eg: http://localhost:3000/relation/database m.Get("/relation/:word", func(params martini.Params) string { relations := Db.GetPopularWordRelations(params["word"]) return `{"result": ["` + strings.Join(relations, `", "`) + `"]}` }) // eg: http://localhost:3000/popular-relations/ m.Get("/popular-relations/", func(params martini.Params) string { relations := Db.GetMostPopularWords() return `{"result": ["` + strings.Join(relations, `", "`) + `"]}` }) // eg: http://localhost:3000/info/ m.Get("/info/", func() string { info := Db.GetAnalysedTextBlocksCounter() return `{"result": {"analysedTextBlocks": "` + info + `"}}` }) // actual launch the server m.Run() }