diff --git a/transport/http.go b/transport/http.go index acb902b..2d92daf 100644 --- a/transport/http.go +++ b/transport/http.go @@ -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) }