From 19b94807904a316efe983901ac7819ab6b2fae28 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Sat, 13 Feb 2016 23:53:07 +0100 Subject: [PATCH] stats: Add web API for words --- stats/web.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stats/web.go b/stats/web.go index d1cdf02..16d14ef 100644 --- a/stats/web.go +++ b/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) }