Support all of paths which end with slash

This commit is contained in:
Naoki Takezoe
2018-03-22 01:39:02 +09:00
parent 1a16edd140
commit 329a8ebc2b

View File

@@ -43,6 +43,15 @@ abstract class ControllerBase extends ScalatraFilter
contentType = formats("json")
}
override def requestPath(uri: String, idx: Int): String = {
val path = super.requestPath(uri, idx)
if(path != "/" && path.endsWith("/")){
path.substring(0, path.length - 1)
} else {
path
}
}
override def doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain): Unit = try {
val httpRequest = request.asInstanceOf[HttpServletRequest]
val context = request.getServletContext.getContextPath