File tree Expand file tree Collapse file tree
src/main/java/io/github/easy4j/hermes Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package io .github .easy4j .hermes ;
22import io .github .easy4j .hermes .api .HermesApiConstants ;
3+ import io .github .easy4j .hermes .security .EndpointPolicy ;
34import lombok .Data ;
45
56import java .util .Objects ;
@@ -57,6 +58,9 @@ public HermesHttpClientConfig(HermesDebugConfig debug) {
5758 */
5859 private String baseUrl = HermesApiConstants .DEFAULT_SERVER_URL ;
5960
61+ /** Explicit endpoint trust policy. Defaults to the historical strict public-host policy. */
62+ private EndpointPolicy endpointPolicy = EndpointPolicy .strictPublic ();
63+
6064 /**
6165 * 仅供测试代码使用——调用 {@link #markUnsafeBaseUrlOverriddenForTest(boolean)}
6266 * 打开后,{@link #setBaseUrl(String)} 跳过 {@link io.github.easy4j.hermes.util.EndpointGuard}
@@ -207,10 +211,21 @@ public void markUnsafeBaseUrlOverriddenForTest(boolean value) {
207211
208212 public HermesHttpClientConfig setBaseUrl (String baseUrl ) {
209213 if (!this .unsafeBaseUrlOverriddenForTest ) {
210- this .baseUrl = io . github . easy4j . hermes . util . EndpointGuard .require (baseUrl );
214+ this .baseUrl = this . endpointPolicy .require (baseUrl );
211215 } else {
212216 this .baseUrl = baseUrl ;
213217 }
214218 return this ;
215219 }
220+
221+ public HermesHttpClientConfig setEndpointPolicy (EndpointPolicy endpointPolicy ) {
222+ this .endpointPolicy = Objects .requireNonNull (endpointPolicy , "endpointPolicy" );
223+ return this ;
224+ }
225+
226+ public String requireBaseUrl () {
227+ return this .unsafeBaseUrlOverriddenForTest
228+ ? this .baseUrl
229+ : this .endpointPolicy .require (this .baseUrl );
230+ }
216231}
You can’t perform that action at this time.
0 commit comments