-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve reactive rest client "process paths before sub resources" sce…
…nario (#995) There is an issue in upstream (quarkusio/quarkus#29821) that only happens under some RestClient definition hierarchy. This commit reproduces the problem in Quarkus 2.12 and earlier versions
- Loading branch information
Pablo Gonzalez Granados
authored
Jan 16, 2023
1 parent
3385b18
commit 2350b46
Showing
10 changed files
with
114 additions
and
125 deletions.
There are no files selected for viewing
51 changes: 0 additions & 51 deletions
51
...ient-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/PlainRootResource.java
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
...tive/src/main/java/io/quarkus/ts/http/restclient/reactive/ReactiveClientRootResource.java
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
...e/src/main/java/io/quarkus/ts/http/restclient/reactive/ResourceAndSubResourcesClient.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,40 @@ | ||
package io.quarkus.ts.http.restclient.reactive; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
|
||
@RegisterRestClient | ||
@RegisterClientHeaders | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public interface ResourceAndSubResourcesClient { | ||
@Path("clients") | ||
ClientsResource clients(); | ||
|
||
interface ClientsResource { | ||
@Path("{id}") | ||
ClientResource get(@PathParam("id") String id); | ||
} | ||
|
||
interface ClientResource { | ||
@Path("/resource-server") | ||
SubResource sub(); | ||
} | ||
|
||
interface LeafResource { | ||
@GET | ||
String retrieve(); | ||
} | ||
|
||
interface SubResource { | ||
@Path("{id}") | ||
LeafResource findById(@PathParam("id") String id); | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
...ent-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/SubResourcesClient.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...estclient/reactive/PlainBookResource.java → ...reactive/resources/PlainBookResource.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
44 changes: 44 additions & 0 deletions
44
...ain/java/io/quarkus/ts/http/restclient/reactive/resources/PlainComplexClientResource.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,44 @@ | ||
package io.quarkus.ts.http.restclient.reactive.resources; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.eclipse.microprofile.rest.client.RestClientBuilder; | ||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
|
||
import io.quarkus.ts.http.restclient.reactive.ResourceAndSubResourcesClient; | ||
|
||
@Path("clients/{clientId}/clientResource") | ||
@Consumes("text/plain") | ||
@Produces("text/plain") | ||
public class PlainComplexClientResource { | ||
@Inject | ||
@RestClient | ||
ResourceAndSubResourcesClient resourceAndSubResourcesClient; | ||
|
||
@GET | ||
@Path("/{id}") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String getClientResource(@PathParam("clientId") String rootParam, | ||
@PathParam("id") String id, | ||
@QueryParam("baseUri") String baseUri) throws URISyntaxException { | ||
|
||
ResourceAndSubResourcesClient restClient = resourceAndSubResourcesClient; | ||
if (!StringUtils.isEmpty(baseUri)) { | ||
restClient = RestClientBuilder.newBuilder().baseUri(new URI(baseUri)) | ||
.build(ResourceAndSubResourcesClient.class); | ||
} | ||
|
||
return restClient.clients().get(rootParam).sub().findById(id).retrieve(); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
.../java/io/quarkus/ts/http/restclient/reactive/resources/ReactivecomplexClientResource.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,14 @@ | ||
package io.quarkus.ts.http.restclient.reactive.resources; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
|
||
@Path("/clients/{rootPath}/resource-server") | ||
public class ReactivecomplexClientResource { | ||
@Path("/{id}") | ||
@GET | ||
public String retrieveById(@PathParam("rootPath") String rootPath, @PathParam("id") String id) { | ||
return "/clients/" + rootPath + "/resource-server/" + id; | ||
} | ||
} |
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