Package io.mochaapi.client.internal
Class DefaultHttpClientEngine
java.lang.Object
io.mochaapi.client.internal.DefaultHttpClientEngine
- All Implemented Interfaces:
HttpClientEngine
Default implementation of HttpClientEngine using Java 11+ HttpClient.
Handles HTTP requests with automatic JSON serialization, timeouts, and error handling.
- Since:
- 1.0.0 Enhanced with configurable timeouts and improved error handling
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DefaultHttpClientEngine with default configuration.DefaultHttpClientEngine(HttpClient httpClient, JsonMapper jsonMapper) Creates a new DefaultHttpClientEngine with custom HttpClient and JsonMapper.DefaultHttpClientEngine(Duration connectTimeout, Duration readTimeout, Duration writeTimeout) Creates a new DefaultHttpClientEngine with custom timeout configuration. -
Method Summary
Modifier and TypeMethodDescriptionexecute(ApiRequest request) Executes an HTTP request and returns the response.
-
Constructor Details
-
DefaultHttpClientEngine
public DefaultHttpClientEngine()Creates a new DefaultHttpClientEngine with default configuration. Uses 30-second timeouts for all operations. -
DefaultHttpClientEngine
public DefaultHttpClientEngine(Duration connectTimeout, Duration readTimeout, Duration writeTimeout) Creates a new DefaultHttpClientEngine with custom timeout configuration.- Parameters:
connectTimeout- the connection timeoutreadTimeout- the read timeoutwriteTimeout- the write timeout
-
DefaultHttpClientEngine
Creates a new DefaultHttpClientEngine with custom HttpClient and JsonMapper.- Parameters:
httpClient- the custom HttpClient instancejsonMapper- the custom JsonMapper instance
-
-
Method Details
-
execute
Description copied from interface:HttpClientEngineExecutes an HTTP request and returns the response.- Specified by:
executein interfaceHttpClientEngine- Parameters:
request- the configured request- Returns:
- ApiResponse containing the result
-