Giter Club home page Giter Club logo

spring-rest-client-examples's Introduction

CircleCI

Spring Rest Client Examples

This repository is for an example application built in my Spring Framework 5 - Beginner to Guru

You can learn about my Spring Framework 5 Online course here.

spring-rest-client-examples's People

Contributors

springframeworkguru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spring-rest-client-examples's Issues

Excessive .block()-s usage

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);
    }

Expiration date is null

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

.block() call is not supported in thread reactor http nio 4

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.