Class SpaSupport
- java.lang.Object
-
- ru.vyarus.guicey.gsp.app.filter.redirect.SpaSupport
-
public class SpaSupport extends java.lang.ObjectSPA 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
Constructors Constructor Description SpaSupport(boolean enabled, java.lang.String rootMapping, java.lang.String target, java.lang.String noRedirectRegex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidmarkPossibleSpaRoute(javax.servlet.http.HttpServletRequest req, javax.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(javax.servlet.http.HttpServletRequest req, javax.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.
-
-
-
Method Detail
-
markPossibleSpaRoute
public void markPossibleSpaRoute(javax.servlet.http.HttpServletRequest req, javax.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(javax.servlet.http.HttpServletRequest req, javax.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)
-
-