org.scalatra.SslRequirement.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalatra_2.8.2.RC1 Show documentation
Show all versions of scalatra_2.8.2.RC1 Show documentation
The core Scalatra framework
The newest version!
package org.scalatra
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
import java.net.URI
trait SslRequirement extends Handler { self: ScalatraKernel =>
abstract override def handle(req: HttpServletRequest, res: HttpServletResponse) {
_request.withValue(req) {
_response.withValue(res) {
if(!req.isSecure) {
val oldUri = new URI(req.getRequestURL.toString)
val url = new URI("https", oldUri.getAuthority, oldUri.getPath, oldUri.getQuery, oldUri.getFragment).toString
redirect(url)
} else {
super.handle(req, res)
}
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy