From c212d53849144da5622f3944b69008ca5f571d53 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sun, 12 Aug 2018 19:35:13 +0800 Subject: [PATCH] Fix: log api query --- hub/server.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hub/server.go b/hub/server.go index 2a4f7891..cb150067 100644 --- a/hub/server.go +++ b/hub/server.go @@ -82,23 +82,18 @@ func traffic(w http.ResponseWriter, r *http.Request) { } } -type GetLogs struct { - Level string `json:"level"` -} - type Log struct { Type string `json:"type"` Payload string `json:"payload"` } func getLogs(w http.ResponseWriter, r *http.Request) { - req := &GetLogs{} - render.DecodeJSON(r.Body, req) - if req.Level == "" { - req.Level = "info" + levelText := r.URL.Query().Get("level") + if levelText == "" { + levelText = "info" } - level, ok := C.LogLevelMapping[req.Level] + level, ok := C.LogLevelMapping[levelText] if !ok { w.WriteHeader(http.StatusBadRequest) render.JSON(w, r, Error{