Skip to content

Instantly share code, notes, and snippets.

@yedi
Created September 7, 2013 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yedi/106252dde45f40a75f89 to your computer and use it in GitHub Desktop.
Save yedi/106252dde45f40a75f89 to your computer and use it in GitHub Desktop.
(defn add-trailing-slash
[handler]
(fn [request]
(if (.endsWith (:uri request) "/")
(handler request)
(let [newurl (str/replace (:uri request) #"(?<=.)$" "/")]
({:status 301 :headers {"Location" newurl}})))))
(def app (-> app-routes
handler/site
add-trailing-slash
wrap-stateful-session))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment