Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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