Return 404 and empty json for routes
This commit is contained in:
parent
e76e31aa7a
commit
150d347053
|
@ -253,6 +253,11 @@ func (h *Handler) Servers(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(servers) == 0 {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
w.Write([]byte("[]"))
|
||||||
|
return
|
||||||
|
}
|
||||||
json.NewEncoder(w).Encode(servers)
|
json.NewEncoder(w).Encode(servers)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -351,6 +356,12 @@ func (h *Handler) ServerInvites(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(serverInvites) == 0 {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
w.Write([]byte("[]"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
json.NewEncoder(w).Encode(serverInvites)
|
json.NewEncoder(w).Encode(serverInvites)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -372,6 +383,12 @@ func (h *Handler) InviteLog(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(logs) == 0 {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
w.Write([]byte("[]"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
json.NewEncoder(w).Encode(logs)
|
json.NewEncoder(w).Encode(logs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue