stats: Add web API for words
This commit is contained in:
parent
f1da34b658
commit
19b9480790
1 changed files with 9 additions and 1 deletions
10
stats/web.go
10
stats/web.go
|
@ -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)
|
||||
}
|
||||
|
|
Reference in a new issue