Skip to content

Commit

Permalink
[grid] Adding "/wd/hub" route to RouterServer
Browse files Browse the repository at this point in the history
Helps backwards compatibility and should
facilitate users to start with Grid 4.

Fixes SeleniumHQ/docker-selenium#1235
  • Loading branch information
diemol committed Mar 17, 2021
1 parent 4ec0cfc commit 917106e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions java/server/src/org/openqa/selenium/grid/commands/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableSet;

import org.openqa.selenium.BuildInfo;
import org.openqa.selenium.cli.CliCommand;
import org.openqa.selenium.events.EventBus;
Expand Down Expand Up @@ -179,11 +180,12 @@ protected Handlers createHandlers(Config config) {
};

Routable ui = new GridUiRoute();
Routable routerWithSpecChecks = router.with(networkOptions.getSpecComplianceChecks());

HttpHandler httpHandler = combine(
ui,
router.with(networkOptions.getSpecComplianceChecks()),
Route.prefix("/wd/hub").to(combine(router.with(networkOptions.getSpecComplianceChecks()))),
routerWithSpecChecks,
Route.prefix("/wd/hub").to(combine(routerWithSpecChecks)),
Route.options("/graphql").to(() -> graphqlHandler),
Route.post("/graphql").to(() -> graphqlHandler),
Route.get("/readyz").to(() -> readinessCheck));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;

import org.openqa.selenium.BuildInfo;
import org.openqa.selenium.cli.CliCommand;
import org.openqa.selenium.grid.TemplateGridServerCommand;
Expand Down Expand Up @@ -63,6 +64,7 @@
import static org.openqa.selenium.grid.config.StandardGridRoles.SESSION_MAP_ROLE;
import static org.openqa.selenium.grid.config.StandardGridRoles.SESSION_QUEUER_ROLE;
import static org.openqa.selenium.net.Urls.fromUri;
import static org.openqa.selenium.remote.http.Route.combine;
import static org.openqa.selenium.remote.http.Route.get;

@AutoService(CliCommand.class)
Expand Down Expand Up @@ -143,10 +145,13 @@ protected Handlers createHandlers(Config config) {
getServerVersion());

Routable ui = new GridUiRoute();
Routable routerWithSpecChecks = new Router(tracer, clientFactory, sessions, queuer, distributor)
.with(networkOptions.getSpecComplianceChecks());

Route handler = Route.combine(
ui,
new Router(tracer, clientFactory, sessions, queuer, distributor).with(networkOptions.getSpecComplianceChecks()),
routerWithSpecChecks,
Route.prefix("/wd/hub").to(combine(routerWithSpecChecks)),
Route.options("/graphql").to(() -> graphqlHandler),
Route.post("/graphql").to(() -> graphqlHandler),
get("/readyz").to(() -> req -> new HttpResponse().setStatus(HTTP_NO_CONTENT)));
Expand Down

0 comments on commit 917106e

Please sign in to comment.