Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some path fixes that was a regression between 1.x and 2 #16366

Merged
merged 1 commit into from Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -534,16 +534,18 @@ void registerGraphQLUiHandler(
smallRyeGraphQLBuildItem.getGraphqlUiPath(), runtimeConfig);
routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route(graphQLConfig.ui.rootPath)
.displayOnNotFoundPage("GraphQL UI")
.routeConfigKey("quarkus.smallrye-graphql.ui.root-path")
.displayOnNotFoundPage("MicroProfile GraphQL UI")
.handler(handler)
.requiresLegacyRedirect()
.build());

routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route(graphQLConfig.ui.rootPath + "/*")
.route(graphQLConfig.ui.rootPath + "*")
.handler(handler)
.requiresLegacyRedirect()
.build());

}
}

Expand Down
Expand Up @@ -43,13 +43,13 @@ public void handle(RoutingContext event) {
.setWebRoot(graphqlUiFinalDestination)
.setDefaultContentEncoding("UTF-8");

if (event.normalisedPath().length() == graphqlUiPath.length()) {
if (event.normalizedPath().length() == graphqlUiPath.length()) {

event.response().setStatusCode(302);
event.response().headers().set(HttpHeaders.LOCATION, graphqlUiPath + "/");
event.response().end();
return;
} else if (event.normalisedPath().length() == graphqlUiPath.length() + 1) {
} else if (event.normalizedPath().length() == graphqlUiPath.length() + 1) {
event.reroute(graphqlUiPath + "/index.html");
return;
}
Expand Down
Expand Up @@ -463,12 +463,19 @@ void registerHealthUiHandler(
Handler<RoutingContext> handler = recorder.uiHandler(smallRyeHealthBuildItem.getHealthUiFinalDestination(),
smallRyeHealthBuildItem.getHealthUiPath(), runtimeConfig);
routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route(healthConfig.ui.rootPath + "*")
.routeConfigKey("quarkus.smallrye-health.ui.root-path")
.route(healthConfig.ui.rootPath)
.displayOnNotFoundPage("Health UI")
.routeConfigKey("quarkus.smallrye-health.ui.root-path")
.handler(handler)
.requiresLegacyRedirect()
.build());

routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route(healthConfig.ui.rootPath + "*")
.handler(handler)
.requiresLegacyRedirect()
.build());

}
}

Expand Down
Expand Up @@ -43,12 +43,12 @@ public void handle(RoutingContext event) {
.setWebRoot(healthUiFinalDestination)
.setDefaultContentEncoding("UTF-8");

if (event.normalisedPath().length() == healthUiPath.length()) {
if (event.normalizedPath().length() == healthUiPath.length()) {
event.response().setStatusCode(302);
event.response().headers().set(HttpHeaders.LOCATION, healthUiPath + "/");
event.response().end();
return;
} else if (event.normalisedPath().length() == healthUiPath.length() + 1) {
} else if (event.normalizedPath().length() == healthUiPath.length() + 1) {
event.reroute(healthUiPath + "/index.html");
return;
}
Expand Down
Expand Up @@ -8,7 +8,7 @@ public class SmallRyeIndividualHealthGroupHandler extends SmallRyeHealthHandlerB

@Override
protected SmallRyeHealth getHealth(SmallRyeHealthReporter reporter, RoutingContext ctx) {
String group = ctx.normalisedPath().substring(ctx.normalisedPath().lastIndexOf("/") + 1);
String group = ctx.normalizedPath().substring(ctx.normalizedPath().lastIndexOf("/") + 1);
return reporter.getHealthGroup(group);
}
}
Expand Up @@ -157,12 +157,18 @@ public void registerSwaggerUiHandler(SwaggerUiRecorder recorder,
runtimeConfig);

routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route(swaggerUiConfig.path + "*")
.route(swaggerUiConfig.path)
.displayOnNotFoundPage("Open API UI")
.routeConfigKey("quarkus.swagger-ui.path")
.handler(handler)
.requiresLegacyRedirect()
.build());

routes.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route(swaggerUiConfig.path + "*")
.handler(handler)
.requiresLegacyRedirect()
.build());
}
}

Expand Down
Expand Up @@ -43,12 +43,12 @@ public void handle(RoutingContext event) {
.setWebRoot(swaggerUiFinalDestination)
.setDefaultContentEncoding("UTF-8");

if (event.normalisedPath().length() == swaggerUiPath.length()) {
if (event.normalizedPath().length() == swaggerUiPath.length()) {
event.response().setStatusCode(302);
event.response().headers().set(HttpHeaders.LOCATION, swaggerUiPath + "/");
event.response().end();
return;
} else if (event.normalisedPath().length() == swaggerUiPath.length() + 1) {
} else if (event.normalizedPath().length() == swaggerUiPath.length() + 1) {
event.reroute(swaggerUiPath + "/index.html");
return;
}
Expand Down
Expand Up @@ -23,6 +23,7 @@
import io.quarkus.qute.Template;
import io.quarkus.qute.TemplateInstance;
import io.vertx.core.Handler;
import io.vertx.core.http.HttpHeaders;
import io.vertx.ext.web.RoutingContext;

/**
Expand All @@ -41,6 +42,7 @@ public class DevConsole implements Handler<RoutingContext> {
final Map<String, Object> globalData = new HashMap<>();

final Config config = ConfigProvider.getConfig();
final String devRootAppend;

DevConsole(Engine engine, String httpRootPath, String frameworkRootPath) {
this.engine = engine;
Expand All @@ -49,7 +51,8 @@ public class DevConsole implements Handler<RoutingContext> {
this.globalData.put("frameworkRootPath", frameworkRootPath);

// This includes the dev segment, but does not include a trailing slash (for append)
this.globalData.put("devRootAppend", frameworkRootPath + "dev");
this.devRootAppend = frameworkRootPath + "dev";
this.globalData.put("devRootAppend", devRootAppend);

this.globalData.put("quarkusVersion", Version.getVersion());
this.globalData.put("applicationName", config.getOptionalValue("quarkus.application.name", String.class).orElse(""));
Expand All @@ -76,7 +79,15 @@ public class DevConsole implements Handler<RoutingContext> {

@Override
public void handle(RoutingContext ctx) {
String path = ctx.normalisedPath().substring(ctx.mountPoint().length());
// Redirect /q/dev to /q/dev/
if (ctx.normalizedPath().length() == devRootAppend.length()) {
ctx.response().setStatusCode(302);
ctx.response().headers().set(HttpHeaders.LOCATION, devRootAppend + "/");
ctx.response().end();
return;
}

String path = ctx.normalizedPath().substring(ctx.mountPoint().length() + 1);
if (path.isEmpty() || path.equals("/")) {
sendMainPage(ctx);
} else {
Expand Down
Expand Up @@ -234,7 +234,7 @@ public void handle(RoutingContext event) {
.handler(new DevConsole(engine, httpRootPath, frameworkRootPath));
mainRouter = Router.router(devConsoleVertx);
mainRouter.errorHandler(500, errorHandler);
mainRouter.route(nonApplicationRootPathBuildItem.resolvePath("dev/*")).subRouter(router);
mainRouter.route(nonApplicationRootPathBuildItem.resolvePath("dev*")).subRouter(router);
}

@BuildStep(onlyIf = IsDevelopment.class)
Expand Down