Created
September 17, 2012 10:55
-
-
Save sunkencity/3736683 to your computer and use it in GitHub Desktop.
compojure test
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
(defn | |
^{:doc "Action that shows the help and about page." | |
:path "/help" | |
:http_method :get} | |
action-show | |
[account member] | |
(normal-layout account | |
[:div | |
[:h1 "Title"] | |
[:p "lorem") | |
(defmacro generate-route-for | |
[action] | |
(let [path# (-> action resolve meta :path) | |
method# (if (= (-> action resolve meta :http_method) :post) 'POST 'GET) | |
arglist# (-> action resolve meta :arglists first) | |
keywords# (map keyword arglist#) | |
symbols# (map gensym arglist#) | |
hsh# (apply hash-map (flatten (map vector symbols# keywords#))) | |
] | |
`(~method# ~path# ~hsh# (~action ~@symbols#)))) | |
(defroutes app-routes | |
(generate-route-for index/action-show) | |
(generate-route-for help/action-show)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment