A macro to define handler for compojure
A macro to define handler for compojure that match parameters automatically.
(defmacro defhandler
[name args & body]
`(defn ~name [req#]
(let [{:keys ~args :or {~'req req#}} (:params req#)]
~@body)))
Then use it define the handler and routes:
(defhandler signup [username password]
....)
(defroutes app-routes
(POST "/signup" [] signup)
Written by dennis zhuang
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Clojure
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#