Skip to content

Instantly share code, notes, and snippets.

@wilig
Created March 5, 2010 05:12
Show Gist options
  • Save wilig/322462 to your computer and use it in GitHub Desktop.
Save wilig/322462 to your computer and use it in GitHub Desktop.
(def route-list (atom {}))
(defmacro with-name
[name route]
(swap! route-list assoc name (nth route 1))
route)
;; Needs to get fancier to handle generating routes with parameters
(defn url-for
[route-name]
(route-name @route-list))
;; Now we can...
(defroutes webauth-public
(with-name :login (GET "/login" (controller/login)))
(with-name :forgot (GET "/forgot-password" (controller/forgot-password)))
(with-name :signup (GET "/signup" (controller/signup)))
(with-name :activate (GET "/activate/:token" (controller/activate params))))
@roanosullivan
Copy link

What's your mileage on this so far? Any reason I should look elsewhere for named routes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment