Skip to content

Commit

Permalink
CB-4896 redirect welcome mode (redirect from '/' to index.html)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-skoblikov committed Sep 16, 2024
1 parent 1b7c9f4 commit 13ee969
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.ee10.servlet.DefaultServlet;
import org.eclipse.jetty.ee10.servlet.ResourceServlet;
import org.eclipse.jetty.server.ResourceService;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.auth.SMAuthInfo;
Expand All @@ -54,6 +54,12 @@ public class CBStaticServlet extends DefaultServlet {

private static final Log log = Log.getLog(CBStaticServlet.class);

@Override
public void init() throws ServletException {
super.init();
this.getResourceService().setWelcomeMode(ResourceService.WelcomeMode.REDIRECT);
}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
for (WebServletHandlerDescriptor handler : WebHandlerRegistry.getInstance().getServletHandlers()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ public ProxyResourceHandler(@NotNull Path contentRoot) {
public boolean handle(Request request, Response response, Callback callback) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String pathInContext = Request.getPathInContext(request);
if (!pathInContext.endsWith("index.html") && !pathInContext.endsWith("sso.html")) {

if (pathInContext == null || !pathInContext.endsWith("index.html")
&& !pathInContext.endsWith("sso.html")
&& !pathInContext.endsWith("ssoError.html")
) {
return super.handle(request, response, callback);
}

if (pathInContext.startsWith("/")) {
pathInContext = pathInContext.substring(1);
}
Expand Down

0 comments on commit 13ee969

Please sign in to comment.