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)
|
||||
return
|
||||
}
|
||||
if len(servers) == 0 {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte("[]"))
|
||||
return
|
||||
}
|
||||
json.NewEncoder(w).Encode(servers)
|
||||
return
|
||||
}
|
||||
|
@ -351,6 +356,12 @@ func (h *Handler) ServerInvites(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if len(serverInvites) == 0 {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte("[]"))
|
||||
return
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(serverInvites)
|
||||
return
|
||||
}
|
||||
|
@ -372,6 +383,12 @@ func (h *Handler) InviteLog(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if len(logs) == 0 {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte("[]"))
|
||||
return
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(logs)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue