From 33c950d256a2831440abb75e354931c0cfa14a38 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 27 Oct 2021 23:43:52 +0200 Subject: [PATCH] Avoid using http.Fluster in cluster replication API --- cmd/admin-handlers-site-replication.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/admin-handlers-site-replication.go b/cmd/admin-handlers-site-replication.go index 80cf66093..7eb010141 100644 --- a/cmd/admin-handlers-site-replication.go +++ b/cmd/admin-handlers-site-replication.go @@ -265,12 +265,13 @@ func (a adminAPIHandlers) SiteReplicationInfo(w http.ResponseWriter, r *http.Req return } - if err = json.NewEncoder(w).Encode(info); err != nil { + jsonBytes, err := json.Marshal(info) + if err != nil { writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL) return } - w.(http.Flusher).Flush() + writeSuccessResponseJSON(w, jsonBytes) } func (a adminAPIHandlers) SRInternalGetIDPSettings(w http.ResponseWriter, r *http.Request) { @@ -284,12 +285,14 @@ func (a adminAPIHandlers) SRInternalGetIDPSettings(w http.ResponseWriter, r *htt } idpSettings := globalSiteReplicationSys.GetIDPSettings(ctx) - if err := json.NewEncoder(w).Encode(idpSettings); err != nil { + + jsonBytes, err := json.Marshal(idpSettings) + if err != nil { writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL) return } - w.(http.Flusher).Flush() + writeSuccessResponseJSON(w, jsonBytes) } func readJSONBody(ctx context.Context, body io.Reader, v interface{}, encryptionKey string) APIErrorCode {