From 7a0717830c4912b85834a27b9e5827a7bd596030 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Wed, 13 Feb 2019 23:45:43 +0800 Subject: [PATCH] Fix: api invalid returning --- hub/route/proxies.go | 4 ++-- hub/route/rules.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hub/route/proxies.go b/hub/route/proxies.go index 404d1a32..3da30a24 100644 --- a/hub/route/proxies.go +++ b/hub/route/proxies.go @@ -59,7 +59,7 @@ func findProxyByName(next http.Handler) http.Handler { func getProxies(w http.ResponseWriter, r *http.Request) { proxies := T.Instance().Proxies() - render.JSON(w, r, map[string]map[string]C.Proxy{ + render.JSON(w, r, render.M{ "proxies": proxies, }) } @@ -129,7 +129,7 @@ func getProxyDelay(w http.ResponseWriter, r *http.Request) { render.Status(r, http.StatusServiceUnavailable) render.JSON(w, r, newError("An error occurred in the delay test")) } else { - render.JSON(w, r, map[string]int16{ + render.JSON(w, r, render.M{ "delay": t, }) } diff --git a/hub/route/rules.go b/hub/route/rules.go index b8cd3aeb..6a223ab5 100644 --- a/hub/route/rules.go +++ b/hub/route/rules.go @@ -24,7 +24,7 @@ type Rule struct { func getRules(w http.ResponseWriter, r *http.Request) { rawRules := T.Instance().Rules() - var rules []Rule + rules := []Rule{} for _, rule := range rawRules { rules = append(rules, Rule{ Type: rule.RuleType().String(), @@ -33,7 +33,7 @@ func getRules(w http.ResponseWriter, r *http.Request) { }) } - render.JSON(w, r, map[string][]Rule{ + render.JSON(w, r, render.M{ "rules": rules, }) }