Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
@amalloy amalloy
19 lines (17 sloc) 0.742 kB
(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)))
Jump to Line
Something went wrong with that request. Please try again.