(refs #279)Override ScalatraBase#fullUrl() to apply the configured base url to redirection.

This commit is contained in:
takezoe
2014-03-01 15:19:42 +09:00
parent 590b431ec1
commit 17f581f654
2 changed files with 13 additions and 9 deletions

View File

@@ -103,15 +103,21 @@ abstract class ControllerBase extends ScalatraFilter
if(request.getMethod.toUpperCase == "POST"){
org.scalatra.Unauthorized(redirect("/signin"))
} else {
val currentUrl = baseUrl + defining(request.getQueryString){ queryString =>
request.getRequestURI.substring(request.getContextPath.length) + (if(queryString != null) "?" + queryString else "")
}
session.setAttribute(Keys.Session.Redirect, currentUrl)
org.scalatra.Unauthorized(redirect("/signin"))
org.scalatra.Unauthorized(redirect("/signin?redirect=" + StringUtil.urlEncode(
defining(request.getQueryString){ queryString =>
request.getRequestURI.substring(request.getContextPath.length) + (if(queryString != null) "?" + queryString else "")
}
)))
}
}
}
override def fullUrl(path: String, params: Iterable[(String, Any)] = Iterable.empty,
includeContextPath: Boolean = true, includeServletPath: Boolean = true)
(implicit request: HttpServletRequest, response: HttpServletResponse) =
if (path.startsWith("http")) path
else baseUrl + url(path, params, includeContextPath, includeServletPath)
}
/**