Package com.styra.opa.utils
Class OPAHTTPClient
java.lang.Object
com.styra.opa.utils.OPAHTTPClient
- All Implemented Interfaces:
HTTPClient
- Direct Known Subclasses:
OPALatencyMeasuringHTTPClient
This HTTPClient implementation also injects additional headers provided to
its constructor into each HTTP request that it sends. This is meant to be
used as the HTTP client implementation for instances of the Speakeasy
generated OPA SDK.
-
Constructor Summary
ConstructorsConstructorDescriptionIf instantiated with this constructor, OPAHTTPClient will be initialized with an empty list of extra headers to inject.OPAHTTPClient
(Map<String, String> extraHeaders) Instantiates a new HTTP client suitable for use with the Speakeasy SDK, but with additional headers included in every request. -
Method Summary
Modifier and TypeMethodDescriptionsend
(HttpRequest request) This method implements compatibility with the com.styra.opa.sdk.utils.HTTPClient interface.
-
Constructor Details
-
OPAHTTPClient
Instantiates a new HTTP client suitable for use with the Speakeasy SDK, but with additional headers included in every request.- Parameters:
extraHeaders
- The extra headers to include.
-
OPAHTTPClient
public OPAHTTPClient()If instantiated with this constructor, OPAHTTPClient will be initialized with an empty list of extra headers to inject.
-
-
Method Details
-
send
public HttpResponse<InputStream> send(HttpRequest request) throws IOException, InterruptedException, URISyntaxException This method implements compatibility with the com.styra.opa.sdk.utils.HTTPClient interface.- Specified by:
send
in interfaceHTTPClient
- Parameters:
request
- HTTP request- Returns:
- HTTP response
- Throws:
IOException
InterruptedException
URISyntaxException
-