Created
May 14, 2012 16:25
-
-
Save stephanos/2694899 to your computer and use it in GitHub Desktop.
play https
This file contains hidden or 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
| protected case class Encrypted[A](action: Action[A]) extends Action[A] { | |
| def apply(req: Request[A]) = { | |
| EnvUtil.isCloud match { | |
| case true => | |
| req.headers.get("x-forwarded-proto") match { | |
| case Some("https") => action(req) | |
| case _ => redirectToHttps(req) | |
| } | |
| case _ => | |
| action(req) | |
| } | |
| } | |
| lazy val parser = action.parser | |
| } | |
| protected def redirectToHttps(req: RequestHeader, customPath: String = null) = { | |
| val protocol = if (EnvUtil.isCloud) "https://" else "http://" | |
| Redirect(protocol + req.headers.get("host").get + Option(customPath).getOrElse(req.uri)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment