List of usage examples for org.springframework.web.reactive.function.client ClientRequest method
@Deprecated
static Builder method(HttpMethod method, URI url)
From source file:top.zhacker.ms.reactor.spring.function.Client.java
public void printAllPeople() { URI uri = URI.create(String.format("http://%s:%d/person", Server.HOST, Server.PORT)); ClientRequest request = ClientRequest.method(HttpMethod.GET, uri).build(); Flux<Person> people = exchange.exchange(request).flatMapMany(response -> response.bodyToFlux(Person.class)); Mono<List<Person>> peopleList = people.collectList(); System.out.println(peopleList.block()); }
From source file:top.zhacker.ms.reactor.spring.function.Client.java
public void createPerson() { URI uri = URI.create(String.format("http://%s:%d/person", Server.HOST, Server.PORT)); Person jack = new Person("Jack Doe", 16); ClientRequest request = ClientRequest.method(HttpMethod.POST, uri).body(BodyInserters.fromObject(jack)) .build();// w ww . j a va 2s .c om Mono<ClientResponse> response = exchange.exchange(request); System.out.println(response.block().statusCode()); }