Skip to content

Commit

Permalink
Config to build HTTPClient using settings from system properties
Browse files Browse the repository at this point in the history
  • Loading branch information
domivds committed Feb 23, 2025
1 parent 227bc38 commit 03b03d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Then setup the routing configuration like this:
```yaml
cognizone:
vinz:
httpClient:
useSystemProperties: true/false # (default false) - since v2.0.1
routes:
- name: firstRoute # just a name, make it unique, nothing else special here
path: /proxy/route1/** # the path on your server (if you use a servlet context path, this will be the part after the context path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.util.AntPathMatcher;

import jakarta.servlet.http.HttpServletRequest;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -34,6 +35,12 @@ private boolean matches(Route route, HttpServletRequest request) {
@Data
public static class Configuration {
private List<Route> routes = Collections.synchronizedList(new ArrayList<>());
private HttpClient httpClient = new HttpClient();
}

@Data
public static class HttpClient {
private boolean useSystemProperties;
}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.core.Ordered;

import jakarta.servlet.Filter;

import java.util.Optional;

@SuppressWarnings("ClassHasNoToStringMethod")
Expand Down Expand Up @@ -62,7 +63,8 @@ public FilterRegistrationBean<Filter> vinzClorthoCacheBodyFilter() {

@Bean
public HttpClientFactory httpClientFactory() {
return () -> HttpClientBuilder.create().build();
return vinzClorthoConfig().getHttpClient().isUseSystemProperties() ? () -> HttpClientBuilder.create().useSystemProperties().build()
: () -> HttpClientBuilder.create().build();
}

}
Expand Down

0 comments on commit 03b03d2

Please sign in to comment.