Created
August 28, 2009 12:24
-
-
Save oranenj/176962 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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