diff --git a/cmd/server/files.go b/cmd/server/files.go index ea4a0f4e..b53cd0ab 100644 --- a/cmd/server/files.go +++ b/cmd/server/files.go @@ -201,7 +201,12 @@ func deleteFile(logger log.Logger, repo WireFileRepository) http.HandlerFunc { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(`{"error": null}`) + + type response struct { + Error error `json:"error"` + } + + json.NewEncoder(w).Encode(&response{Error: nil}) } } @@ -287,7 +292,12 @@ func validateFile(logger log.Logger, repo WireFileRepository) http.HandlerFunc { logger.Log("validated file") w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(`{"error": null}`) + + type response struct { + Error error `json:"error"` + } + + json.NewEncoder(w).Encode(&response{Error: nil}) } } diff --git a/cmd/server/files_test.go b/cmd/server/files_test.go index b78d01fa..c9088f6d 100644 --- a/cmd/server/files_test.go +++ b/cmd/server/files_test.go @@ -264,6 +264,7 @@ func TestFiles_deleteFile(t *testing.T) { w.Flush() assert.Equal(t, http.StatusOK, w.Code, w.Body) + assert.Contains(t, w.Body.String(), `{"error":null}`) }) t.Run("repo error", func(t *testing.T) { @@ -411,8 +412,7 @@ func TestFiles_validateFile(t *testing.T) { router.ServeHTTP(w, req) w.Flush() - assert.Equal(t, http.StatusOK, w.Code, w.Body) - assert.Contains(t, w.Body.String(), `"{\"error\": null}"`) + assert.Contains(t, w.Body.String(), `{"error":null}`) }) t.Run("repo error", func(t *testing.T) {