From b0eac61d82c9e03cf9b2eb646b3acabb49c02acb Mon Sep 17 00:00:00 2001 From: Joe Dytrych Date: Wed, 17 Feb 2016 22:10:04 +0000 Subject: separate functions for json & html responses --- src/pronouns/pages.clj | 9 +++++---- src/pronouns/web.clj | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj index bdcd9d6..8aed689 100644 --- a/src/pronouns/pages.clj +++ b/src/pronouns/pages.clj @@ -135,7 +135,8 @@ (apply format-pronouns pronouns) (not-found)))) -(defn pronouns [path pronouns-table accept] - (if (= accept :json) - (pronouns-page path pronouns-table format-pronoun-json not-found-json) - (pronouns-page path pronouns-table format-pronoun-examples not-found))) +(defn pronouns [path pronouns-table] + (pronouns-page path pronouns-table format-pronoun-examples not-found)) + +(defn pronouns-json [path pronouns-table] + (pronouns-page path pronouns-table format-pronoun-json not-found-json)) diff --git a/src/pronouns/web.clj b/src/pronouns/web.clj index bf717eb..5af441f 100644 --- a/src/pronouns/web.clj +++ b/src/pronouns/web.clj @@ -32,10 +32,10 @@ (if (= "application/json" (.toLowerCase (get headers "accept"))) {:status 200 :headers {"Content-Type" "application/json"} - :body (pages/pronouns (:* params) pronouns-table :json)} + :body (pages/pronouns-json (:* params) pronouns-table)} {:status 200 :headers {"Content-Type" "text/html"} - :body (pages/pronouns (:* params) pronouns-table :html)})) + :body (pages/pronouns (:* params) pronouns-table)})) (ANY "*" [] (route/not-found (slurp (io/resource "404.html"))))) -- cgit