feat(http): core outbound HTTP interfaces and property records

This commit is contained in:
hsiegeln
2026-04-19 15:39:57 +02:00
parent ffdfd6cd9a
commit 2224f7d902
5 changed files with 59 additions and 0 deletions

View File

@@ -37,6 +37,10 @@
<artifactId>spring-security-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>

View File

@@ -0,0 +1,8 @@
package com.cameleer.server.core.http;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
public interface OutboundHttpClientFactory {
/** Returns a memoized client configured for the given TLS/timeout context. */
CloseableHttpClient clientFor(OutboundHttpRequestContext context);
}

View File

@@ -0,0 +1,20 @@
package com.cameleer.server.core.http;
import java.time.Duration;
import java.util.List;
public record OutboundHttpProperties(
boolean trustAll,
List<String> trustedCaPemPaths,
Duration defaultConnectTimeout,
Duration defaultReadTimeout,
String proxyUrl,
String proxyUsername,
String proxyPassword
) {
public OutboundHttpProperties {
trustedCaPemPaths = trustedCaPemPaths == null ? List.of() : List.copyOf(trustedCaPemPaths);
if (defaultConnectTimeout == null) defaultConnectTimeout = Duration.ofMillis(2000);
if (defaultReadTimeout == null) defaultReadTimeout = Duration.ofMillis(5000);
}
}

View File

@@ -0,0 +1,20 @@
package com.cameleer.server.core.http;
import java.time.Duration;
import java.util.List;
public record OutboundHttpRequestContext(
TrustMode trustMode,
List<String> trustedCaPemPaths,
Duration connectTimeout,
Duration readTimeout
) {
public OutboundHttpRequestContext {
if (trustMode == null) trustMode = TrustMode.SYSTEM_DEFAULT;
trustedCaPemPaths = trustedCaPemPaths == null ? List.of() : List.copyOf(trustedCaPemPaths);
}
public static OutboundHttpRequestContext systemDefault() {
return new OutboundHttpRequestContext(TrustMode.SYSTEM_DEFAULT, List.of(), null, null);
}
}

View File

@@ -0,0 +1,7 @@
package com.cameleer.server.core.http;
public enum TrustMode {
SYSTEM_DEFAULT,
TRUST_ALL,
TRUST_PATHS
}