springframeworkguru / spring-rest-client-examples Goto Github PK
View Code? Open in Web Editor NEWSpring Rest Client Examples
Spring Rest Client Examples
http://apifaketory.com/api/user?limit=10 is no longer available.
I am using http://private-anon-ce456ed119-apifaketory.apiary-mock.com/api/user?limit=1
as an interim solution. However, it returns only 1 user regardless of limit
param
when mapping between json format and Card object, the expiration_date field is null, it is not mapped correctly, to map it you have to add the @JsonProperty ("expiration_date") annotation in the Card class and the same annotation on the getter and setter, also you have to do the same thing for the timezoneType field in the ExpirationDate class
Throughout this and other repos here .block() is used excessively. Should n't it be dropped (e.g. it seems that nio 4 does not support calling it).
So the next code:
@Override
public Flux<User> getUsers(Mono<Integer> limit) {
return WebClient
.create(api_url)
.get()
.uri(uriBuilder -> uriBuilder.queryParam("limit", limit.block()).build())
.accept(MediaType.APPLICATION_JSON)
.exchange()
.flatMap(resp -> resp.bodyToMono(UserData.class))
.flatMapIterable(UserData::getData);
}
should be rewritten into more non-blocking style:
public Flux<User> getUsers(Mono<Integer> limit) {
return limit
.map(l -> UriComponentsBuilder
.fromUriString(api_url)
.queryParam("limit", l).toUriString()
)
.map(urlString -> WebClient.create(urlString))
.map(WebClient::get)
.map(spec -> spec.accept(MediaType.APPLICATION_JSON))
.flatMap(WebClient.RequestHeadersSpec::exchange)
.flatMap(resp -> resp.bodyToMono(UserData.class))
.flatMapIterable(UserData::getData);
}
Whitelabel Error Page
This application has no configured error view, so you are seeing this as a fallback.
Tue Sep 03 17:20:45 PDT 2019
There was an unexpected error (type=Internal Server Error, status=500).
block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-4
It seems that here, standard subscription mechanism should be used instead of manually calling .block
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.