Fix: log api query
This commit is contained in:
parent
3df8ee56d6
commit
c212d53849
1 changed files with 4 additions and 9 deletions
|
@ -82,23 +82,18 @@ func traffic(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetLogs struct {
|
|
||||||
Level string `json:"level"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Log struct {
|
type Log struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Payload string `json:"payload"`
|
Payload string `json:"payload"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLogs(w http.ResponseWriter, r *http.Request) {
|
func getLogs(w http.ResponseWriter, r *http.Request) {
|
||||||
req := &GetLogs{}
|
levelText := r.URL.Query().Get("level")
|
||||||
render.DecodeJSON(r.Body, req)
|
if levelText == "" {
|
||||||
if req.Level == "" {
|
levelText = "info"
|
||||||
req.Level = "info"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
level, ok := C.LogLevelMapping[req.Level]
|
level, ok := C.LogLevelMapping[levelText]
|
||||||
if !ok {
|
if !ok {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
render.JSON(w, r, Error{
|
render.JSON(w, r, Error{
|
||||||
|
|
Loading…
Reference in a new issue