Noir's routing is more strict than some others, so take a look at this question which, while having a different title, is asking the same thing.
How do I make a page visible with or without ending slash in the url?
Question
I use noir.
Having :
(defpage "/welcome" [] "Welcome to Noir!")
I do I make both these URL works:
http://localhost:8080/welcome
http://localhost:8080/welcome/
Thanks!
EDIT: Here's the complete answer.
In server.clj
, add up (:use [ring.util.response :only [redirect]])
Then write :
(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))))
(server/add-middleware wrap-slash)
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow