diff options
author | Morgan Astra <m@morganastra.me> | 2018-11-16 19:20:47 -0800 |
---|---|---|
committer | Morgan Astra <m@morganastra.me> | 2018-11-16 19:20:47 -0800 |
commit | d25a9680835694656564d961e300077f49b2fab7 (patch) | |
tree | cfb0e908f8c3a3a32eba3fbc226675a42c7a8d37 /src/pronouns/pages.clj | |
parent | d150af49370a2d70710a50c6cc2e38bf1a72868f (diff) |
Make API response for success and failure cases the same shape json-api
Diffstat (limited to 'src/pronouns/pages.clj')
-rw-r--r-- | src/pronouns/pages.clj | 15 |
1 files 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)) |