--- a/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Thu May 13 18:01:56 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Thu May 13 19:31:09 2021 +0200 @@ -86,6 +86,12 @@ request.setAttribute(Constants.REQ_ATTR_REDIRECT_LOCATION, baseHref + value) } + var feedPath = "" + set(value) { + field = value + request.setAttribute(Constants.REQ_ATTR_FEED_HREF, baseHref + value) + } + /** * The view object. * @@ -98,9 +104,21 @@ } /** + * Additional port info, if necessary. + */ + private val portInfo = + if ((request.scheme == "http" && request.serverPort == 80) + || (request.scheme == "https" && request.serverPort == 443) + ) "" else ":${request.serverPort}" + + /** * The base path of this application. */ - val baseHref get() = "${request.scheme}://${request.serverName}:${request.serverPort}${request.contextPath}/" + val baseHref get() = "${request.scheme}://${request.serverName}$portInfo${request.contextPath}/" + + init { + feedPath = "feed/projects.rss" + } private fun String.withExt(ext: String) = if (endsWith(ext)) this else plus(ext) private fun jspPath(name: String) = Constants.JSP_PATH_PREFIX.plus(name).withExt(".jsp") @@ -108,10 +126,15 @@ fun param(name: String): String? = request.getParameter(name) fun paramArray(name: String): Array<String> = request.getParameterValues(name) ?: emptyArray() - fun forward(jsp: String) { + private fun forward(jsp: String) { request.getRequestDispatcher(jspPath(jsp)).forward(request, response) } + fun renderFeed(page: String? = null) { + page?.let { contentPage = it } + forward("feed") + } + fun render(page: String? = null) { page?.let { contentPage = it } forward("site")