9 ms·
I mentioned this on another submission but Christophe Grand's Moustache routing library, http://github.com/cgrand/moustache http://github.com/cgrand/moustache,
by swannodette 17y ago
I mentioned this on another submission but Christophe Grand's Moustache routing library, http://github.com/cgrand/moustache http://github.com/cgrand/moustache, is great in conjunction with Ring. It makes very idiomatic use of destructuring to define routes, for example you can do stuff like the following:
(def admin-post
(app [""] "admin post index" ; /admin/post/ or /admin/post
["new"] {:get new-post ; GET /admin/post/new
:post save-post} ; POST /admin/post/new
["edit" id] {:get edit-post})) ; GET /admin/post/edit/:id
(def admin
(app [""] "admin index" ; /admin/ or /admin
["post" &] admin-post
["posts"] {:get all-posts} ; /admin/posts
["settings"] {:get settings})) ; /admin/settings
(def main
(app [""] "index page" ; /
["post" slug] {:get get-post} ; /post/:slug
["admin" &] admin))