[Grid] Add Grid Console URL back
import org.openqa.selenium.grid.server.Server;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.grid.sessionmap.local.LocalSessionMap;
+import org.openqa.selenium.grid.web.ClassPathResource;
import org.openqa.selenium.grid.web.CombinedHandler;
+import org.openqa.selenium.grid.web.NoHandler;
+import org.openqa.selenium.grid.web.ResourceHandler;
import org.openqa.selenium.grid.web.RoutableHttpClientFactory;
+import org.openqa.selenium.json.Json;
import org.openqa.selenium.netty.server.NettyServer;
import org.openqa.selenium.remote.http.Contents;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpHandler;
import org.openqa.selenium.remote.http.HttpResponse;
+import org.openqa.selenium.remote.http.Routable;
import org.openqa.selenium.remote.http.Route;
import org.openqa.selenium.remote.tracing.Tracer;
import java.util.logging.Logger;
import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR;
+import static java.net.HttpURLConnection.HTTP_MOVED_TEMP;
import static java.net.HttpURLConnection.HTTP_OK;
import static org.openqa.selenium.grid.config.StandardGridRoles.EVENT_BUS_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.HTTPD_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.ROUTER_ROLE;
import static org.openqa.selenium.remote.http.Route.combine;
+import static org.openqa.selenium.remote.http.Route.get;
@AutoService(CliCommand.class)
public class Hub extends TemplateGridCommand {
@@ -140,7 +147,21 @@ protected void execute(Config config) {
.setContent(Contents.utf8String("Router is " + ready));
};
+ Routable ui;
+ URL uiRoot = getClass().getResource("/javascript/grid-ui/build");
+ if (uiRoot != null) {
+ ResourceHandler
+ uiHandler = new ResourceHandler(new ClassPathResource(uiRoot, "javascript/grid-ui/build"));
+ ui = Route.combine(
+ get("/grid/console").to(() -> req -> new HttpResponse().setStatus(HTTP_MOVED_TEMP).addHeader("Location", "/ui/index.html")),
+ Route.prefix("/ui/").to(Route.matching(req -> true).to(() -> uiHandler)));
+ } else {
+ Json json = new Json();
+ ui = Route.matching(req -> false).to(() -> new NoHandler(json));
+ }
+
HttpHandler httpHandler = combine(
+ ui,
router.with(networkOptions.getSpecComplianceChecks()),
Route.prefix("/wd/hub").to(combine(router.with(networkOptions.getSpecComplianceChecks()))),
Route.post("/graphql").to(() -> graphqlHandler),
