From d25a9680835694656564d961e300077f49b2fab7 Mon Sep 17 00:00:00 2001 From: Morgan Astra Date: Fri, 16 Nov 2018 19:20:47 -0800 Subject: Make API response for success and failure cases the same shape --- src/pronouns/pages.clj | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj index 8922234..a90cc85 100644 --- a/src/pronouns/pages.clj +++ b/src/pronouns/pages.clj @@ -226,10 +226,17 @@ (not-found-fn path)))) (defn format-pronoun-json [pronouns] - (json/write-str pronouns)) - -(defn not-found-json [] - (json/write-str {:error "Not found"})) + (json/write-str {:api-version "0.1" + :status :ok + :pronouns (first pronouns) + :alt-pronouns (rest pronouns)})) + +(defn not-found-json [_] + (json/write-str {:api-version "0.1" + :status :not-found + :error "Not found" + :pronouns [] + :alt-pronouns []})) (defn pronouns-json [params] (pronouns params format-pronoun-json not-found-json)) -- cgit