From 292853b51d596c941650ae525b8e5e8e5aa9b2ac Mon Sep 17 00:00:00 2001 From: Umputun Date: Sat, 19 May 2018 11:35:47 -0500 Subject: [PATCH] fix prev comment --- app/rest/api/rest.go | 5 ++++- app/rest/api/rest_test.go | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/rest/api/rest.go b/app/rest/api/rest.go index b0954777..a7457185 100644 --- a/app/rest/api/rest.go +++ b/app/rest/api/rest.go @@ -336,7 +336,7 @@ func (s *Rest) lastCommentsCtrl(w http.ResponseWriter, r *http.Request) { filterDeleted = append(filterDeleted, c) } - return encodeJSONWithHTML(comments) + return encodeJSONWithHTML(filterDeleted) }) if err != nil { @@ -425,6 +425,9 @@ func (s *Rest) configCtrl(w http.ResponseWriter, r *http.Request) { authNames = append(authNames, ap.Name) } cnf.Auth = authNames + if s.Authenticator.Admins == nil { // prevent json serialization to nil + s.Authenticator.Admins = []string{} + } render.Status(r, http.StatusOK) render.JSON(w, r, cnf) } diff --git a/app/rest/api/rest_test.go b/app/rest/api/rest_test.go index 50e6b800..53d19c00 100644 --- a/app/rest/api/rest_test.go +++ b/app/rest/api/rest_test.go @@ -487,8 +487,8 @@ func prep(t *testing.T) (srv *Rest, ts *httptest.Server) { } func withBasicAuth(r *http.Request, username, password string) *http.Request { - auth := username + ":" + password - r.Header.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(auth))) + creds := username + ":" + password + r.Header.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(creds))) return r }