From 7279075e07e21dc18f86e3308adfafcb50a9e6d1 Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 6 Apr 2014 16:48:06 -0400 Subject: [PATCH] add resource handler for searching art names --- src/toascii/routes/api/art.clj | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/toascii/routes/api/art.clj diff --git a/src/toascii/routes/api/art.clj b/src/toascii/routes/api/art.clj new file mode 100644 index 0000000..75bd4f9 --- /dev/null +++ b/src/toascii/routes/api/art.clj @@ -0,0 +1,17 @@ +(ns toascii.routes.api.art + (:require [liberator.core :refer [defresource]] + [compojure.core :refer [ANY]] + [toascii.route-utils :refer [register-routes]] + [toascii.models.art :as art])) + +(defresource art-search [q] + :available-media-types ["application/json"] + :malformed? + (fn [_] + (not (art/valid-name? q))) + :handle-ok + (fn [_] + (art/search q))) + +(register-routes api-art-routes + (ANY "/api/art" {{q :q} :params} (art-search q)))