-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #602 from fedinskiy/feature/reactive-rest-part-2
Reactive REST client, part2
- Loading branch information
Showing
23 changed files
with
410 additions
and
17 deletions.
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
68 changes: 68 additions & 0 deletions
68
...rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/BookClient.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,68 @@ | ||
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.Produces; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
|
||
import io.quarkus.ts.http.restclient.reactive.json.Book; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@RegisterRestClient | ||
@Path("/books") | ||
@RegisterClientHeaders | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public interface BookClient { | ||
|
||
@GET | ||
@Path("/") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
Uni<Book> getBook(@QueryParam("title") String title, @QueryParam("author") String author); | ||
|
||
@Path("/author") | ||
AuthorClient getAuthor(); | ||
|
||
@Consumes(MediaType.TEXT_PLAIN) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
interface AuthorClient { | ||
@GET | ||
@Path("/name") | ||
Uni<String> getName(@QueryParam("author") String author); | ||
|
||
@Path("profession") | ||
ProfessionClient getProfession(); | ||
} | ||
|
||
@Consumes(MediaType.TEXT_PLAIN) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
interface ProfessionClient { | ||
@GET | ||
@Path("/name") | ||
Uni<String> getName(); | ||
|
||
@Path("/wage") | ||
WageClient getWage(); | ||
} | ||
|
||
interface WageClient { | ||
@GET | ||
@Path("/amount") | ||
String getAmount(); | ||
|
||
@Path("/currency") | ||
CurrencyClient getCurrency(); | ||
} | ||
|
||
interface CurrencyClient { | ||
@GET | ||
@Path("/name") | ||
String getName(); | ||
} | ||
|
||
} |
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
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
2 changes: 1 addition & 1 deletion
2
.../ts/http/restclient/reactive/OsUtils.java → ...tp/restclient/reactive/files/OsUtils.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
2 changes: 1 addition & 1 deletion
2
...http/restclient/reactive/IdBeanParam.java → ...restclient/reactive/json/IdBeanParam.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
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
31 changes: 31 additions & 0 deletions
31
...ient-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/proxy/ProxyClient.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,31 @@ | ||
package io.quarkus.ts.http.restclient.reactive.proxy; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
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; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
@RegisterRestClient | ||
@RegisterClientHeaders | ||
public interface ProxyClient { | ||
|
||
@GET | ||
@Path("/") | ||
@Produces(MediaType.TEXT_HTML) | ||
Uni<String> getSite(); | ||
|
||
@GET | ||
@Path("/example.txt") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
Uni<String> getText(); | ||
|
||
@GET | ||
@Path("/auth") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
Uni<String> getAuthorized(); | ||
} |
41 changes: 41 additions & 0 deletions
41
...nt-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/proxy/ProxyResource.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,41 @@ | ||
package io.quarkus.ts.http.restclient.reactive.proxy; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
@Path("/proxied") | ||
public class ProxyResource { | ||
|
||
@Inject | ||
@RestClient | ||
ProxyClient client; | ||
|
||
@GET | ||
@Path("/") | ||
@Produces(MediaType.TEXT_HTML) | ||
public Uni<String> getRoot() { | ||
return client.getSite(); | ||
} | ||
|
||
@GET | ||
@Path("/banned") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Uni<String> getBanned() { | ||
return client.getText(); | ||
} | ||
|
||
@GET | ||
@Path("/authorization") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Uni<String> getAuthorized() { | ||
return client.getAuthorized(); | ||
} | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
http/rest-client-reactive/src/main/resources/classic.properties
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
io.quarkus.ts.http.restclient.reactive.ReactiveRestInterface/mp-rest/url=http://localhost:${quarkus.http.port} | ||
io.quarkus.ts.http.restclient.reactive.json.JsonRestInterface/mp-rest/url=http://localhost:${quarkus.http.port} | ||
io.quarkus.ts.http.restclient.reactive.BookClient/mp-rest/url=http://localhost:${quarkus.http.port} |
6 changes: 5 additions & 1 deletion
6
http/rest-client-reactive/src/main/resources/modern.properties
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# new schema introduced in https://github.com/quarkusio/quarkus/pull/17220 . See classic.properties for old-style settings | ||
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.ReactiveRestInterface".url=http://localhost:${quarkus.http.port} | ||
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.json.JsonRestInterface".url=http://localhost:${quarkus.http.port} | ||
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.files.FileClient".url=http://localhost:${quarkus.http.port} | ||
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.BookClient".url=http://localhost:${quarkus.http.port} | ||
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.BookClient.AuthorClient".url=http://localhost:${quarkus.http.port} | ||
quarkus.rest-client.logging.scope=request-response | ||
quarkus.log.category."org.jboss.resteasy.reactive.client.logging".level=DEBUG | ||
quarkus.http.limits.max-body-size=3G | ||
quarkus.rest-client.read-timeout = 120000 |
6 changes: 6 additions & 0 deletions
6
http/rest-client-reactive/src/main/resources/proxy.properties
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,6 @@ | ||
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.proxy.ProxyClient".url=http://example.com | ||
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.proxy.ProxyClient".proxy-address=localhost:8090 | ||
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.proxy.ProxyClient".proxy-user=proxyuser | ||
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.proxy.ProxyClient".proxy-password=proxypassword | ||
quarkus.rest-client.logging.scope=request-response | ||
quarkus.log.category."org.jboss.resteasy.reactive.client.logging".level=DEBUG |
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
Oops, something went wrong.