Skip to content

Instantly share code, notes, and snippets.

@sunkencity
Created September 17, 2012 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sunkencity/3736683 to your computer and use it in GitHub Desktop.
Save sunkencity/3736683 to your computer and use it in GitHub Desktop.
compojure test
(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