Package ru.vyarus.guicey.spa.filter
Class SpaRoutingFilter
java.lang.Object
ru.vyarus.guicey.spa.filter.SpaRoutingFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
Filter must be mapped to assets servlet, serving spa application.
Bypass all calls to servlet, but if servlet returns 404, tries to redirect to application main page.
This is important to properly handle html5 client routing (without hashbang).
In order to route, filter checks request accept header: if it's compatible with "text/html" - routing is performed. If not, 404 error sent. Also, regex pattern is used to prevent routing (for example, for html templates). This is important for all other assets, which absence must be indicated.
- Since:
- 02.04.2017
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SpaRoutingFilter
-
-
Method Details
-
init
public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException - Specified by:
initin interfacejakarta.servlet.Filter- Throws:
jakarta.servlet.ServletException
-
doFilter
public void doFilter(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException - Specified by:
doFilterin interfacejakarta.servlet.Filter- Throws:
IOExceptionjakarta.servlet.ServletException
-
destroy
public void destroy()- Specified by:
destroyin interfacejakarta.servlet.Filter
-