-
Notifications
You must be signed in to change notification settings - Fork 35
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 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
committed
Jan 16, 2023
1 parent
2fad57f
commit 477d065
Showing
10 changed files
with
113 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.DELETE; | ||
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 { | ||
@DELETE | ||
String remove(); | ||
} | ||
|
||
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
43 changes: 43 additions & 0 deletions
43
...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,43 @@ | ||
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.DELETE; | ||
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; | ||
|
||
@DELETE | ||
@Path("/{id}") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String deleteClientResource(@PathParam("clientId") String rootParam, | ||
@PathParam("id") String id, | ||
@QueryParam("baseUri") String baseUri) throws URISyntaxException { | ||
if (!StringUtils.isEmpty(baseUri)) { | ||
ResourceAndSubResourcesClient rClient = RestClientBuilder.newBuilder().baseUri(new URI(baseUri)) | ||
.build(ResourceAndSubResourcesClient.class); | ||
return rClient.clients().get(rootParam).sub().findById(id).remove(); | ||
} | ||
|
||
return resourceAndSubResourcesClient.clients().get(rootParam).sub().findById(id).remove(); | ||
} | ||
} |
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.DELETE; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
|
||
@Path("/clients/{rootPath}/resource-server") | ||
public class ReactivecomplexClientResource { | ||
@Path("/{id}") | ||
@DELETE | ||
public String deleteById(@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