forked from 4clojure/4clojure
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.clj
More file actions
18 lines (17 loc) · 742 Bytes
/
Copy pathapi.clj
File metadata and controls
18 lines (17 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(ns foreclojure.api
(:require [cheshire.core :as json])
(:use [foreclojure.ring :only [wrap-json wrap-debug]]
[foreclojure.utils :only [as-int]]
[compojure.core :only [routes GET]]
[somnium.congomongo :only [fetch-one]]
[useful.map :only [update-each]]))
(def api-routes
(-> (routes
(GET "/api/problem/:id" [id]
(when-let [problem (fetch-one :problems :where {:_id (as-int id)
:approved true})]
{:body (-> problem
(dissoc :_id :approved)
(update-each [:restricted :tags]
#(or % ())))})))
(wrap-json)))