Class SpaSupport
java.lang.Object
ru.vyarus.guicey.gsp.app.filter.redirect.SpaSupport
SPA routes support (HTML5 client routing). Support rely on errors handling: when 404 error appear (no matter
in assets or views), spa support is checked (if enabled) and spa redirection performed instead of error handling.
Error based approach does not influence normal processing: all checks appear only after error appearance (so enabling SPA support will not influence application).
Also, SPA support forcefully sets no cache header for index page (or any route, redirected to index page).
- Since:
- 16.01.2019
-
Constructor Summary
ConstructorsConstructorDescriptionSpaSupport(boolean enabled, String rootMapping, String target, String noRedirectRegex) -
Method Summary
Modifier and TypeMethodDescriptionvoidmarkPossibleSpaRoute(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Simple to check for root page: if current request is already root request then no SPA route could be performed.booleanredirect(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, int code) Perform redirection of SPA into index page (so browser receive index html on spa routing url) if conditions match.
-
Constructor Details
-
SpaSupport
-
-
Method Details
-
markPossibleSpaRoute
public void markPossibleSpaRoute(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Simple to check for root page: if current request is already root request then no SPA route could be performed. Also, applies no cache header for the root page.- Parameters:
req- request instanceres- response instance
-
redirect
public boolean redirect(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, int code) Perform redirection of SPA into index page (so browser receive index html on spa routing url) if conditions match.- SPA support enabled
- It't not already root (see
markPossibleSpaRoute(HttpServletRequest, HttpServletResponse)) - Request accept html response
- Request doesn't match filter regexp (describing static files)
- Parameters:
req- request instanceres- response instancecode- error code (http)- Returns:
- true if redirection performed, false otherwise (SPA route not recognized)
-