Ejemplo n.º 1
0
// JSON handler for getting all solutions. Still needed!
func handlerWordRacer(w http.ResponseWriter, r *http.Request) {
	queryMap := r.URL.Query()
	lang := queryMap.Get("lang")
	correctWordDictFileName, _ := langToDictFile[lang] // correctWordDictFileName = "allWords.txt"
	checker := spoj.NewChecker(correctWordDictFileName)
	content := queryMap.Get("board")
	length := queryMap.Get("length")
	lines := getLines(content, length)
	words := spoj.WordRacerFromServer(checker, lines)
	// Should use JSON here.
	output := strings.Join(words, ",")
	fmt.Fprintf(w, output)
}
Ejemplo n.º 2
0
func handleGetAllWords(w http.ResponseWriter, r *http.Request) {
	checker := spoj.NewChecker("allWords.txt")
	words := checker.AllWords()
	output := strings.Join(words, ",")
	fmt.Fprintf(w, output)
}