I am developing a web application with Clojure, currently with Ring , Mustache , Sandbar and Hiccup . I have a resource called job and a route to show a specific step in a multi-step form for a specific job defined this way (other routes are omitted for simplicity):
(def web-app
(moustache/app
;; matches things like "/job/32/foo/bar"
:get [["job" id & step]
(fn [req] (web.controllers.job/show-job id step))]))
In the view that my controller displays, there are links to other steps as part of the same work. Currently, these URLs are created manually, for example. (str "/job/" id step). I don't like this encoded "/job/"portion of the URL because it repeats what I defined in the mustache route; if I change the route, I need to change my controller, which is a closer connection than I need.
I know that the Rails routing system has methods for generating URLs from parameters, and I would like for me to have similar functionality, that is, I would like to have a function url-forthat I could name as follows:
(url-for :job 32 "foo" "bar")
; => "/job/32/foo/bar"
Is there a Clojure web framework that makes this easier? If not, what are your thoughts on how this can be implemented?