I'm helping to set up a Web site with Clojure's Noir framework, though I have a lot more experience with Django/Python. In Django, I'm used to URLs such as
http://site/some/url
being 302-redirected automagically to
http://site/some/url/
Noir is more picky and does not do this.
What would be the proper way to do this automatically? Since good URLs are an important way of addressing into a site, and many users will forget the trailing slash, this is basic functionality I'd like to add to my site.
EDIT: Here is what finally worked for me, based on @IvanKoblik's suggestions:
(defn wrap-slash [handler]
(fn [{:keys [uri] :as req}]
(if (and (.endsWith uri "/") (not= uri "/"))
(handler (assoc req :uri (.substring uri
0 (dec (count uri)))))
(handler req))))