Skip to content

Instantly share code, notes, and snippets.

@oranenj
Created August 28, 2009 12:24
Show Gist options
  • Save oranenj/176962 to your computer and use it in GitHub Desktop.
Save oranenj/176962 to your computer and use it in GitHub Desktop.
(ns net.licenser.clresource
(:use compojure))
(defroutes greeter
(GET "/"
(html [:h1 "Hello World"])))
(def *current-resource*)
(defmacro resource [name & body]
`(binding [~'*current-resource* ~name]
~@body))
(defmacro list-items [& body]
`(GET (str "/" *current-resource* ".json")
~@body))
(defmacro get-item [p & body]
`(GET (str "/" *current-resource* "/:id.json")
(let [~p [(params :id)]]
~@body)))
(defmacro create-item [p & body]
`(PUT (str "/" *current-resource** ".json")
(let [~p [params]]
~@body)))
(defmacro update-item [p & body]
`(GET (str "/" *current-resource* "/:id.json")
(let [~p [(params :id) params]]
~@body)))
(defmacro delete-item [p & body]
`(DELETE (str "/" *current-resource* "/:id.json")
(let [~p [(params :id)]]
~@body)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment