Skip to content

Instantly share code, notes, and snippets.

@remvee
Created September 28, 2010 14:49
Show Gist options
  • Save remvee/601124 to your computer and use it in GitHub Desktop.
Save remvee/601124 to your computer and use it in GitHub Desktop.
Ring middleware to force a SSL connection
(defn wrap-force-ssl [app]
(fn [req]
(if (= :https (:scheme req))
(app req)
(let [url (str "https://" (:server-name req) (:uri req))]
{:status 302
:headers {"Location" url, "Content-Type" "text/html"}
:body (str "<html><body><a href='" url "'>redirecting..</a.></body></html>")}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment