Package com.styra.opa.utils
Class OPAHTTPClient
- java.lang.Object
-
- com.styra.opa.utils.OPAHTTPClient
-
- All Implemented Interfaces:
HTTPClient
- Direct Known Subclasses:
OPALatencyMeasuringHTTPClient
public class OPAHTTPClient extends java.lang.Object implements HTTPClient
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
Constructors Constructor Description OPAHTTPClient()
If instantiated with this constructor, OPAHTTPClient will be initialized with an empty list of extra headers to inject.OPAHTTPClient(java.util.Map<java.lang.String,java.lang.String> extraHeaders)
Instantiates a new HTTP client suitable for use with the Speakeasy SDK, but with additional headers included in every request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.http.HttpResponse<java.io.InputStream>
send(java.net.http.HttpRequest request)
This method implements compatibility with the com.styra.opa.sdk.utils.HTTPClient interface.
-
-
-
Constructor Detail
-
OPAHTTPClient
public OPAHTTPClient(java.util.Map<java.lang.String,java.lang.String> extraHeaders)
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 Detail
-
send
public java.net.http.HttpResponse<java.io.InputStream> send(java.net.http.HttpRequest request) throws java.io.IOException, java.lang.InterruptedException, java.net.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:
java.io.IOException
java.lang.InterruptedException
java.net.URISyntaxException
-
-