Skip to content

Instantly share code, notes, and snippets.

@podviaznikov
Created May 17, 2013 04:57
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 podviaznikov/5597012 to your computer and use it in GitHub Desktop.
Save podviaznikov/5597012 to your computer and use it in GitHub Desktop.
how to force https traffic in clojure web app
(defn https-url [request-url]
(str (str (str (str "https://" (:server-name request-url) ":") "443")) (:uri request-url)))
(defn require-https
[handler]
(fn [request]
(if (= (:scheme request) :http)
(ring.util.response/redirect (https-url request))
(handler request))))
(def war-handler
(-> app
(require-https)
(wrap-resource "public")
(wrap-base-url)
(wrap-file-info)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment