Revise HttpRequestFunctionConfiguration configuration (#295)
Fixes #286
This commit is contained in:
@@ -43,14 +43,23 @@ The **$$http-request$$** $$processor$$ has the following options:
|
||||
== Options
|
||||
|
||||
//tag::configuration-properties[]
|
||||
$$http.request.body-expression$$:: $$A SpEL expression to derive the request body from the incoming message.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
$$http.request.expected-response-type$$:: $$The type used to interpret the response.$$ *($$Class<?>$$, default: `$$<none>$$`)*
|
||||
$$http.request.headers-expression$$:: $$A SpEL expression used to derive the http headers map to use.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
$$http.request.http-method-expression$$:: $$A SpEL expression to derive the request method from the incoming message.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
$$http.request.maximum-buffer-size$$:: $$Maximum buffer size in bytes allocated for input stream buffers. Defaults to 256k. Increase, as necessary, for posting or getting large binary content.$$ *($$Integer$$, default: `$$0$$`)*
|
||||
$$http.request.reply-expression$$:: $$A SpEL expression used to compute the final result, applied against the whole http {@link org.springframework.http.ResponseEntity}.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
$$http.request.timeout$$:: $$Request timeout in milliseconds.$$ *($$Long$$, default: `$$30000$$`)*
|
||||
$$http.request.url-expression$$:: $$A SpEL expression against incoming message to determine the URL to use.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
Properties grouped by prefix:
|
||||
|
||||
|
||||
=== http.request
|
||||
|
||||
$$body-expression$$:: $$A SpEL expression to derive the request body from the incoming message.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
$$expected-response-type$$:: $$The type used to interpret the response.$$ *($$Class<?>$$, default: `$$<none>$$`)*
|
||||
$$headers-expression$$:: $$A SpEL expression used to derive the http headers map to use.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
$$http-method-expression$$:: $$A SpEL expression to derive the request method from the incoming message.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
$$reply-expression$$:: $$A SpEL expression used to compute the final result, applied against the whole http {@link org.springframework.http.ResponseEntity}.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
$$timeout$$:: $$Request timeout in milliseconds.$$ *($$Long$$, default: `$$30000$$`)*
|
||||
$$url-expression$$:: $$A SpEL expression against incoming message to determine the URL to use.$$ *($$Expression$$, default: `$$<none>$$`)*
|
||||
|
||||
=== spring.codec
|
||||
|
||||
$$log-request-details$$:: $$Whether to log form data at DEBUG level, and headers at TRACE level.$$ *($$Boolean$$, default: `$$false$$`)*
|
||||
$$max-in-memory-size$$:: $$Limit on the number of bytes that can be buffered whenever the input stream needs to be aggregated. This applies only to the auto-configured WebFlux server and WebClient instances. By default this is not set, in which case individual codec defaults apply. Most codecs are limited to 256K by default.$$ *($$DataSize$$, default: `$$<none>$$`)*
|
||||
//end::configuration-properties[]
|
||||
|
||||
//end::ref-doc[]
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
configuration-properties.classes=org.springframework.cloud.fn.http.request.HttpRequestFunctionProperties
|
||||
|
||||
configuration-properties.classes=org.springframework.cloud.fn.http.request.HttpRequestFunctionProperties,\
|
||||
org.springframework.boot.autoconfigure.codec.CodecProperties
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
configuration-properties.classes=org.springframework.cloud.fn.http.request.HttpRequestFunctionProperties
|
||||
configuration-properties.classes=org.springframework.cloud.fn.http.request.HttpRequestFunctionProperties,\
|
||||
org.springframework.boot.autoconfigure.codec.CodecProperties
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2018-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import java.util.function.Function;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -34,11 +33,14 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
import org.springframework.web.util.UriBuilderFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Configuration for a {@link Function} that makes HTTP requests to a resource and for
|
||||
* each request, returns a {@link ResponseEntity}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Sunny Hemdev
|
||||
*
|
||||
**/
|
||||
@Configuration
|
||||
@@ -46,17 +48,8 @@ import org.springframework.web.util.UriBuilderFactory;
|
||||
public class HttpRequestFunctionConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(WebClient.class)
|
||||
public WebClient webClient(HttpRequestFunctionProperties properties) {
|
||||
return WebClient.builder()
|
||||
.codecs(clientCodecConfigurer ->
|
||||
clientCodecConfigurer.defaultCodecs().maxInMemorySize(properties.getMaximumBufferSize()))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HttpRequestFunction httpRequestFunction(WebClient webClient, HttpRequestFunctionProperties properties) {
|
||||
return new HttpRequestFunction(webClient, properties);
|
||||
public HttpRequestFunction httpRequestFunction(WebClient.Builder webClientBuilder, HttpRequestFunctionProperties properties) {
|
||||
return new HttpRequestFunction(webClientBuilder.build(), properties);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
* Copyright 2015-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.cloud.fn.http.request;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Positive;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.expression.Expression;
|
||||
@@ -35,6 +34,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
* @author Christian Tzolov
|
||||
* @author Artem Bilan
|
||||
* @author David Turanski
|
||||
* @author Sunny Hemdev
|
||||
*/
|
||||
@Validated
|
||||
@ConfigurationProperties("http.request")
|
||||
@@ -52,13 +52,6 @@ public class HttpRequestFunctionProperties {
|
||||
*/
|
||||
private long timeout = 30_000;
|
||||
|
||||
/**
|
||||
* Maximum buffer size in bytes allocated for input stream buffers. Defaults to 256k.
|
||||
* Increase, as necessary, for posting or getting large binary content.
|
||||
*/
|
||||
|
||||
private int maximumBufferSize = 256 * 1024;
|
||||
|
||||
/**
|
||||
* A SpEL expression against incoming message to determine the URL to use.
|
||||
*/
|
||||
@@ -119,15 +112,6 @@ public class HttpRequestFunctionProperties {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
@Positive
|
||||
public int getMaximumBufferSize() {
|
||||
return maximumBufferSize;
|
||||
}
|
||||
|
||||
public void setMaximumBufferSize(int maximumBufferSize) {
|
||||
this.maximumBufferSize = maximumBufferSize;
|
||||
}
|
||||
|
||||
public Expression getBodyExpression() {
|
||||
return bodyExpression;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user