Restore debug handler
This commit is contained in:
+12
-25
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/KosyanMedia/burlesque/hub"
|
||||
@@ -17,6 +18,10 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
Version = "0.2.0"
|
||||
)
|
||||
|
||||
func New(port int, h *hub.Hub) *Server {
|
||||
s := Server{
|
||||
port: port,
|
||||
@@ -45,35 +50,17 @@ func (s *Server) statusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (s *Server) debugHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// info := make(map[string]interface{})
|
||||
// info["version"] = version
|
||||
// info["goroutines"] = runtime.NumGoroutine()
|
||||
info := make(map[string]interface{})
|
||||
info["version"] = Version
|
||||
info["gomaxprocs"] = runtime.GOMAXPROCS(-1)
|
||||
info["goroutines"] = runtime.NumGoroutine()
|
||||
info["kyoto_cabinet"] = s.hub.StorageInfo()
|
||||
|
||||
// s, err := storage.Status()
|
||||
// if err != nil {
|
||||
// alert(err, "Failed to get Kyoto Cabinet status")
|
||||
// }
|
||||
// s = s[:len(s)-1] // Removing trailing new line
|
||||
|
||||
// ks := make(map[string]interface{})
|
||||
// tokens := strings.Split(s, "\n")
|
||||
// for _, t := range tokens {
|
||||
// tt := strings.Split(t, "\t")
|
||||
// num, err := strconv.Atoi(tt[1])
|
||||
// if err != nil {
|
||||
// ks[tt[0]] = tt[1]
|
||||
// } else {
|
||||
// ks[tt[0]] = num
|
||||
// }
|
||||
// }
|
||||
// info["kyoto_cabinet"] = ks
|
||||
|
||||
// jsn, _ := json.Marshal(info)
|
||||
// w.Write(jsn)
|
||||
jsn, _ := json.Marshal(info)
|
||||
w.Write(jsn)
|
||||
}
|
||||
|
||||
func (s *Server) pubHandler(w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
msg, _ := ioutil.ReadAll(r.Body)
|
||||
if len(msg) == 0 {
|
||||
msg = []byte(r.FormValue("msg"))
|
||||
|
||||
Reference in New Issue
Block a user