Skip to content

Instantly share code, notes, and snippets.

@jkuipers
Created May 29, 2018 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jkuipers/237b80f117200e64d5b20fc9d0c6a1ce to your computer and use it in GitHub Desktop.
Save jkuipers/237b80f117200e64d5b20fc9d0c6a1ce to your computer and use it in GitHub Desktop.
Type-safe configuration class for the HttpClientAutoConfiguration sample
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("http.client")
public class HttpClientProperties {
private int connectionTimeoutInMillis = 1_000;
private int readTimeoutInMillis = 10_000;
/** Used to configure both the default max per route as well as the maximum total connections. */
private int maxConnections = 200;
/**
* Configures a LoggingClientHttpRequestInterceptor and a BufferingClientHttpRequestFactory,
* so requests and responses can be logged.
*/
private boolean loggingEnabled;
public int getConnectionTimeoutInMillis() {
return connectionTimeoutInMillis;
}
public void setConnectionTimeoutInMillis(int connectionTimeoutInMillis) {
this.connectionTimeoutInMillis = connectionTimeoutInMillis;
}
public int getReadTimeoutInMillis() {
return readTimeoutInMillis;
}
public void setReadTimeoutInMillis(int readTimeoutInMillis) {
this.readTimeoutInMillis = readTimeoutInMillis;
}
public int getMaxConnections() {
return maxConnections;
}
public void setMaxConnections(int maxConnections) {
this.maxConnections = maxConnections;
}
public boolean isLoggingEnabled() {
return loggingEnabled;
}
public void setLoggingEnabled(boolean loggingEnabled) {
this.loggingEnabled = loggingEnabled;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment