List of usage examples for org.springframework.web.reactive.function.client WebClient get
RequestHeadersUriSpec<?> get();
From source file:org.springframework.cloud.function.web.source.HttpSupplier.java
private Flux<?> get(WebClient client) { Flux<?> result = client.get().uri(this.props.getSource().getUrl()).exchange().flatMap(this::transform) .repeat();//from w w w. j a v a 2 s . c o m if (this.props.isDebug()) { result = result.log(); } return result.onErrorResume(TerminateException.class, error -> Mono.empty()); }
From source file:org.springframework.cloud.netflix.hystrix.HystrixWebfluxControllerTests.java
@Test public void hystrixStreamWorks() { String url = "http://localhost:" + port; // you have to hit a Hystrix circuit breaker before the stream sends anything WebTestClient testClient = WebTestClient.bindToServer().baseUrl(url).build(); testClient.get().uri("/").exchange().expectStatus().isOk(); WebClient client = WebClient.create(url); Flux<String> result = client.get().uri(BASE_PATH + "/hystrix.stream").accept(MediaType.TEXT_EVENT_STREAM) .exchange().flatMapMany(res -> res.bodyToFlux(Map.class)).take(5) .filter(map -> "HystrixCommand".equals(map.get("type"))).map(map -> (String) map.get("type")); StepVerifier.create(result).expectNext("HystrixCommand").thenCancel().verify(); }