diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-10-09 09:13:22 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-10-13 17:28:45 -0700 |
commit | eb4a746efcb9e76e29942461b97da797fd67109f (patch) | |
tree | 980663ba01f79bd107980fd0c3205fe833503a41 /pkg/api/handlers | |
parent | 7ad631b819d991559ba20e4728a6803a2546158f (diff) | |
download | podman-eb4a746efcb9e76e29942461b97da797fd67109f.tar.gz podman-eb4a746efcb9e76e29942461b97da797fd67109f.tar.bz2 podman-eb4a746efcb9e76e29942461b97da797fd67109f.zip |
Restore --format table support
* system df
* events
* fix error handling from go routine
* update tests to use gomega matchers for better error messages
* system info
* version
* volume inspect
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/api/handlers')
-rw-r--r-- | pkg/api/handlers/compat/events.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/pkg/api/handlers/compat/events.go b/pkg/api/handlers/compat/events.go index a729b84d4..f74491a8f 100644 --- a/pkg/api/handlers/compat/events.go +++ b/pkg/api/handlers/compat/events.go @@ -112,11 +112,15 @@ func GetEvents(w http.ResponseWriter, r *http.Request) { errorChannel <- runtime.Events(r.Context(), readOpts) }() - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) + var flush = func() {} if flusher, ok := w.(http.Flusher); ok { - flusher.Flush() + flush = flusher.Flush } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + flush() + coder := json.NewEncoder(w) coder.SetEscapeHTML(true) @@ -124,6 +128,7 @@ func GetEvents(w http.ResponseWriter, r *http.Request) { select { case err := <-errorChannel: if err != nil { + // FIXME StatusOK already sent above cannot send 500 here utils.InternalServerError(w, err) return } @@ -136,9 +141,7 @@ func GetEvents(w http.ResponseWriter, r *http.Request) { if err := coder.Encode(e); err != nil { logrus.Errorf("unable to write json: %q", err) } - if flusher, ok := w.(http.Flusher); ok { - flusher.Flush() - } + flush() case <-r.Context().Done(): return } |