Class TemplateRedirect
java.lang.Object
ru.vyarus.guicey.gsp.app.filter.redirect.TemplateRedirect
Performs redirection of template request into rest context. Note that even if no special rest
mapped for template, but request looks like direct file template, it would be rendered with the
DirectTemplateExceptionMapper.
Rest resource convention: /[rest context]/[prefix]/[path from request], where [prefix] is application registration name by default (but may be configured). Additional mappings may be configured to sub url, so redirection to different rest "branches" may be performed, depending on called url.
If resource is annotated with Template annotation (it should!) then
TemplateAnnotationFilter will detect it and set specified template into context TemplateContext.
Important: resources must use TemplateView as base template model class
in order to properly support Template annotation.
- Since:
- 03.12.2018
-
Constructor Summary
ConstructorsConstructorDescriptionTemplateRedirect(jakarta.servlet.Servlet restServlet, String app, String mapping, ViewRestLookup views, AssetLookup assets, ErrorRedirect errorRedirect) -
Method Summary
Modifier and TypeMethodDescriptionvoidredirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String page, io.dropwizard.views.common.ViewRenderer directTemplateRenderer) Redirect template request into rest resource.voidsetRootPath(String contextPath, String servletMapping) static TemplateContext
-
Constructor Details
-
TemplateRedirect
public TemplateRedirect(jakarta.servlet.Servlet restServlet, String app, String mapping, ViewRestLookup views, AssetLookup assets, ErrorRedirect errorRedirect)
-
-
Method Details
-
setRootPath
- Parameters:
contextPath- main context mapping pathservletMapping- rest servlet mapping path
-
redirect
public void redirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String page, io.dropwizard.views.common.ViewRenderer directTemplateRenderer) throws IOException, jakarta.servlet.ServletException Redirect template request into rest resource. Jersey will select appropriate resource by path, or thrown not found exception, received byDirectTemplateExceptionMapper(to render direct template instead).- Parameters:
request- template requestresponse- template responsepage- requested template path (cleared for matching)directTemplateRenderer- vue renderer, recognized template or null- Throws:
IOException- on dispatching errorsjakarta.servlet.ServletException- on dispatching errors
-
getErrorRedirect
- Returns:
- custom error pages support
-
getRootPath
- Returns:
- root rest mapping path
-
templateContext
- Returns:
- thread bound template context or null
-