org.scalatra.MethodOverride.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.{HttpServletRequestWrapper, HttpServletRequest, HttpServletResponse}
trait MethodOverride extends Handler {
abstract override def handle(req: HttpServletRequest, res: HttpServletResponse) {
val req2 = req.getMethod match {
case "POST" =>
req.getParameter(paramName) match {
case null => req
case method => new HttpServletRequestWrapper(req) { override def getMethod = method.toUpperCase }
}
case _ =>
req
}
super.handle(req2, res)
}
private val paramName = "_method"
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy