Created
May 17, 2013 04:57
-
-
Save podviaznikov/5597012 to your computer and use it in GitHub Desktop.
how to force https traffic in clojure web app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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