Java Code Examples for org.springframework.web.reactive.function.client.ClientResponse#statusCode()

The following examples show how to use org.springframework.web.reactive.function.client.ClientResponse#statusCode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpSupplier.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
private Mono<?> transform(ClientResponse response) {
	HttpStatus status = response.statusCode();
	if (!status.is2xxSuccessful()) {
		if (this.props.isDebug()) {
			logger.info("Delaying supplier based on status=" + response.statusCode());
		}
		return Mono.delay(Duration.ofSeconds(1));
	}
	return response.bodyToMono(this.props.getSource().getType())
			.map(value -> message(response, value));
}
 
Example 2
Source File: TestUtils.java    From spring-cloud-gateway with Apache License 2.0 4 votes vote down vote up
public static void assertStatus(ClientResponse response, HttpStatus status) {
	HttpStatus statusCode = response.statusCode();
	assertThat(statusCode).isEqualTo(status);
}
 
Example 3
Source File: ReactiveVaultTemplate.java    From spring-vault with Apache License 2.0 3 votes vote down vote up
private static <T> Mono<? extends T> mapOtherwise(ClientResponse response, String path, HttpMethod method) {

		if (response.statusCode() == HttpStatus.NOT_FOUND && method == HttpMethod.GET) {
			return Mono.empty();
		}

		return response.bodyToMono(String.class).flatMap(body -> {

			String error = VaultResponses.getError(body);

			return Mono.error(VaultResponses.buildException(response.statusCode(), path, error));
		});
	}