Skip to content

Commit

Permalink
Legacy non-application endpoint redirection use case (quarkus-qe#216)
Browse files Browse the repository at this point in the history
quarkus.http.redirect-to-non-application-root-path deprecated property was removed

It is possible to achieve the previous behavior by explicitly setting endpoints to
be absolute instead of relative. For instance, the Health endpoint can be forced to be
available at /health instead of /q/health by setting

quarkus.smallrye-health.root-path=/health
  • Loading branch information
Pablo Gonzalez Granados authored Jun 2, 2021
1 parent 7bfa0f6 commit 19ce4e0
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ quarkus.container-image.name=demo
quarkus.application.name=non-application endpoints
quarkus.http.root-path=/api
quarkus.http.non-application-root-path=/q
quarkus.http.redirect-to-non-application-root-path=true

quarkus.swagger-ui.always-include=true
quarkus.health.openapi.included=true
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class CommonNonAppEndpoint {
protected static final String ROOT_BASE_PATH = "/api/";
protected static final String QUARKUS_PROFILE = "quarkus.profile";
protected static final String NATIVE = "native";
protected static final boolean IS_NATIVE = System.getProperty(QUARKUS_PROFILE, "").equals(NATIVE);
public static final boolean IS_NATIVE = System.getProperty(QUARKUS_PROFILE, "").equals(NATIVE);
private RequestSpecification request;
private RequestSpecBuilder spec;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.quarkus.qe.non_application.endpoint;

import static io.quarkus.qe.non_application.endpoint.CommonNonAppEndpoint.NATIVE;
import static io.quarkus.qe.non_application.endpoint.CommonNonAppEndpoint.QUARKUS_PROFILE;

import org.junit.jupiter.api.condition.EnabledIfSystemProperty;

@EnabledIfSystemProperty(named = QUARKUS_PROFILE, matches = NATIVE)
public class LegacyNonApplicationEndpointIT extends LegacyNonApplicationEndpointTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.quarkus.qe.non_application.endpoint;

import static io.quarkus.qe.non_application.endpoint.CommonNonAppEndpoint.IS_NATIVE;
import static io.restassured.RestAssured.when;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.qe.http.non_application.endpoint.HelloResource;
import io.quarkus.test.QuarkusProdModeTest;

public class LegacyNonApplicationEndpointTest {

@RegisterExtension
static final QuarkusProdModeTest nonApplicationEndpointScenario = new QuarkusProdModeTest()
.setBuildNative(IS_NATIVE)
.overrideConfigKey("quarkus.http.root-path", "/api")
.overrideConfigKey("quarkus.smallrye-health.root-path", "/health")
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClass(HelloResource.class))
.setRun(true);

@Test
protected void nonAppEndpointScenario() {
when().get("/health").then().statusCode(200);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class NonAppEndpointNonRootPathTest extends CommonNonAppEndpoint {
.setBuildNative(IS_NATIVE)
.overrideConfigKey("quarkus.http.root-path", "/api")
.overrideConfigKey("quarkus.http.non-application-root-path", BASE_PATH)
.overrideConfigKey("quarkus.http.redirect-to-non-application-root-path", "false")
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClass(HelloResource.class))
.setRun(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class NonAppEndpointTest extends CommonNonAppEndpoint {
.setBuildNative(IS_NATIVE)
.overrideConfigKey("quarkus.http.root-path", "/api")
.overrideConfigKey("quarkus.http.non-application-root-path", BASE_PATH)
.overrideConfigKey("quarkus.http.redirect-to-non-application-root-path", "false")
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClass(HelloResource.class))
.setRun(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class NonAppEndpointTestNonBaseRootPathTest extends CommonNonAppEndpoint
.setBuildNative(IS_NATIVE)
.overrideConfigKey("quarkus.http.root-path", "/")
.overrideConfigKey("quarkus.http.non-application-root-path", BASE_PATH)
.overrideConfigKey("quarkus.http.redirect-to-non-application-root-path", "false")
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(HelloResource.class))
.setRun(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class RelativePathNonAppEndpointTest extends CommonNonAppEndpoint {
.setBuildNative(IS_NATIVE)
.overrideConfigKey("quarkus.http.root-path", "/api")
.overrideConfigKey("quarkus.http.non-application-root-path", BASE_PATH)
.overrideConfigKey("quarkus.http.redirect-to-non-application-root-path", "false")
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClass(HelloResource.class))
.setRun(true);
Expand Down

0 comments on commit 19ce4e0

Please sign in to comment.