add configuration entry for request timeout
This commit is contained in:
parent
bb3c76a9d9
commit
51c593b8cd
2 changed files with 15 additions and 4 deletions
|
@ -56,6 +56,9 @@ public class ProxyConfig {
|
|||
protected Boolean directBuffers;
|
||||
@JsonProperty("target-url")
|
||||
protected String targetUrl;
|
||||
/** Defaults to 30 seconds */
|
||||
@JsonProperty("target-request-timeout")
|
||||
protected Integer targetRequestTimeout = 30000;
|
||||
@JsonProperty("send-access-token")
|
||||
protected boolean sendAccessToken;
|
||||
@JsonProperty("applications")
|
||||
|
@ -159,6 +162,14 @@ public class ProxyConfig {
|
|||
this.targetUrl = targetUrl;
|
||||
}
|
||||
|
||||
public Integer getTargetRequestTimeout() {
|
||||
return targetRequestTimeout;
|
||||
}
|
||||
|
||||
public void setTargetRequestTimeout(Integer targetRequestTimeout) {
|
||||
this.targetRequestTimeout = targetRequestTimeout;
|
||||
}
|
||||
|
||||
public List<Application> getApplications() {
|
||||
return applications;
|
||||
}
|
||||
|
|
|
@ -97,14 +97,14 @@ public class ProxyServerBuilder {
|
|||
|
||||
protected Map<String, String> headerNameConfig;
|
||||
|
||||
public ProxyServerBuilder target(String uri) {
|
||||
public ProxyServerBuilder target(ProxyConfig config) {
|
||||
SimpleProxyClientProvider provider = null;
|
||||
try {
|
||||
provider = new SimpleProxyClientProvider(new URI(uri));
|
||||
provider = new SimpleProxyClientProvider(new URI(config.getTargetUrl()));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final HttpHandler handler = new ProxyHandler(provider, 30000, ResponseCodeHandler.HANDLE_404);
|
||||
final HttpHandler handler = new ProxyHandler(provider, config.getTargetRequestTimeout(), ResponseCodeHandler.HANDLE_404);
|
||||
proxyHandler = new HttpHandler() {
|
||||
@Override
|
||||
public void handleRequest(HttpServerExchange exchange) throws Exception {
|
||||
|
@ -385,7 +385,7 @@ public class ProxyServerBuilder {
|
|||
log.error("Must set Target URL");
|
||||
return null;
|
||||
}
|
||||
builder.target(config.getTargetUrl());
|
||||
builder.target(config);
|
||||
if (config.getApplications() == null || config.getApplications().size() == 0) {
|
||||
log.error("No applications defined");
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue