Skip to content

Commit

Permalink
chore(debug): add logging for IndexRedirector
Browse files Browse the repository at this point in the history
  • Loading branch information
undx committed Dec 11, 2024
1 parent a893c19 commit 663c358
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,33 @@ public class IndexRedirector implements Filter {
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,
final FilterChain filterChain) throws IOException, ServletException {
final HttpServletRequest httpServletRequest = HttpServletRequest.class.cast(servletRequest);
System.out.println("doFilter with request : " + httpServletRequest.getRequestURI());
if (exists(httpServletRequest.getRequestURI())) {
System.out.println("doFilter : exists");
filterChain.doFilter(servletRequest, servletResponse);
} else {
filterChain.doFilter(new HttpServletRequestWrapper(httpServletRequest) {

@Override
public String getPathInfo() {
System.out.println("doFilter : not exists - path");
return "";
}

@Override
public String getServletPath() {
System.out.println("doFilter : not exists - servlet path");
return "/index.html";
}
}, servletResponse);
}
}

private boolean exists(final String requestURI) {
return requestURI.startsWith("/api") || Stream
Boolean found = requestURI.startsWith("/api") || Stream
.of(".png", ".html", ".js", ".js.map", ".css", ".css.map", ".json", ".ico", ".woff", ".woff2")
.anyMatch(requestURI::contains);
System.out.println(requestURI + " -> " + found);
return found;
}
}

0 comments on commit 663c358

Please sign in to comment.