From 49f27066b881e473d436cb9b29c415e97ef8dbff Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 3 Feb 2020 22:34:36 +0100 Subject: [PATCH] :sparkles: Enable transit encoding parametrization. --- backend/src/uxbox/config.clj | 1 + backend/src/uxbox/http/interceptors.clj | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/src/uxbox/config.clj b/backend/src/uxbox/config.clj index 181b9a8172..9d2d646163 100644 --- a/backend/src/uxbox/config.clj +++ b/backend/src/uxbox/config.clj @@ -31,6 +31,7 @@ :smtp-enabled false :allow-demo-users true :registration-enabled true + :debug-humanize-transit true }) (s/def ::http-server-port ::us/integer) diff --git a/backend/src/uxbox/http/interceptors.clj b/backend/src/uxbox/http/interceptors.clj index eff7fb232b..742606d2a5 100644 --- a/backend/src/uxbox/http/interceptors.clj +++ b/backend/src/uxbox/http/interceptors.clj @@ -2,11 +2,15 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) 2019 Andrey Antukh +;; This Source Code Form is "Incompatible With Secondary Licenses", as +;; defined by the Mozilla Public License, v. 2.0. +;; +;; Copyright (c) 2019-2020 Andrey Antukh (ns uxbox.http.interceptors (:require [vertx.web :as vw] + [uxbox.config :as cfg] [uxbox.common.exceptions :as ex] [uxbox.util.transit :as t]) (:import @@ -30,12 +34,15 @@ (def format-response-body {:leave (fn [{:keys [response] :as data}] - (let [body (:body response)] + (let [body (:body response) + type (if (:debug-humanize-transit cfg/config) + :json-verbose + :json)] (cond (coll? body) (-> data (assoc-in [:response :body] - (t/bytes->buffer (t/encode body))) + (t/bytes->buffer (t/encode body {:type type}))) (update-in [:response :headers] assoc "content-type" "application/transit+json"))