stats: Add web API for words

This commit is contained in:
Hamcha 2016-02-13 23:53:07 +01:00
parent f1da34b658
commit 19b9480790
1 changed files with 9 additions and 1 deletions

View File

@ -20,8 +20,16 @@ func webUsers(rw http.ResponseWriter, req *http.Request) {
}
}
func webWords(rw http.ResponseWriter, req *http.Request) {
err := json.NewEncoder(rw).Encode(words)
if err != nil {
log.Println("[webWords] JSON Encoding error: " + err.Error())
}
}
func startWebServer(bindAddr string) {
http.HandleFunc("/stats", webStats)
http.HandleFunc("/users", webUsers)
http.HandleFunc("/users", webUserNames)
http.HandleFunc("/words", webUserWords)
http.ListenAndServe(bindAddr, nil)
}