-
-
Save kareblak/4493655 to your computer and use it in GitHub Desktop.
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
package unfilteredx.kit | |
import unfiltered.request._ | |
import unfiltered.response._ | |
object Secure { | |
def secure[A,B](intent: unfiltered.Cycle.Intent[A,B]) = { | |
case req@ForwardedProto(proto) if (intent.isDefinedAt(req)) => intent(wrap(req, "https" == proto.toLowerCase)) | |
case req if (intent.isDefinedAt(req)) => intent(req) | |
} | |
private def wrap[A](req: HttpRequest[A], secure: Boolean) = new DelegatingRequest(req) { | |
override def isSecure = secure | |
} | |
} | |
object ForwardedProto extends StringHeader("Forwarded-Proto") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment