-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configuration option for resuming on 404
This is a useful (albeit advanced) option for users that want to use custom routes to handle cases where RESTEasy Reactive does not match the URL path. Closes: #38840
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...loyment/src/test/java/io/quarkus/resteasy/reactive/server/test/ResumeOn404ConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package io.quarkus.resteasy.reactive.server.test; | ||
|
||
import static io.restassured.RestAssured.get; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.enterprise.event.Observes; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
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.test.QuarkusUnitTest; | ||
import io.vertx.ext.web.Router; | ||
|
||
public class ResumeOn404ConfigTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Resource.class, CustomRoute.class); | ||
} | ||
}) | ||
.overrideRuntimeConfigKey("quarkus.resteasy-reactive.resume-on-404", "true"); | ||
|
||
@Test | ||
public void matchingFromResteasyReactive() { | ||
get("/test") | ||
.then() | ||
.statusCode(200); | ||
} | ||
|
||
@Test | ||
public void matchingFromCustomRoute() { | ||
get("/main") | ||
.then() | ||
.statusCode(200); | ||
} | ||
|
||
@Test | ||
public void missing() { | ||
get("/dummy") | ||
.then() | ||
.statusCode(404); | ||
} | ||
|
||
@Path("/test") | ||
@RequestScoped | ||
public static class Resource { | ||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
return "test"; | ||
} | ||
|
||
} | ||
|
||
public static class CustomRoute { | ||
|
||
public void initMain(@Observes Router router) { | ||
router.get("/main").handler(rc -> rc.response().end("main")); | ||
} | ||
} | ||
} |