Queue flushing

This commit is contained in:
2014-09-24 19:37:33 +04:00
parent 9d6d240bbc
commit 12b3a12c51
3 changed files with 41 additions and 0 deletions
+9
View File
@@ -32,6 +32,7 @@ func New(port int, h *hub.Hub) *Server {
http.HandleFunc("/debug", s.debugHandler)
http.HandleFunc("/publish", s.pubHandler)
http.HandleFunc("/subscribe", s.subHandler)
http.HandleFunc("/flush", s.flushHandler)
return &s
}
@@ -97,3 +98,11 @@ func (s *Server) subHandler(w http.ResponseWriter, r *http.Request) {
w.Write(res.Message)
}
}
func (s *Server) flushHandler(w http.ResponseWriter, r *http.Request) {
queues := strings.Split(r.FormValue("queues"), ",")
messages := s.hub.Flush(queues)
jsn, _ := json.Marshal(messages)
w.Write(jsn)
}