configure method
Configure HTTP settings
Implementation
Future<void> configure({
required SDKEnvironment environment,
String? apiKey,
String? baseURL,
String? accessToken,
Map<String, String>? defaultHeaders,
}) async {
_apiKey = apiKey;
_accessToken = accessToken;
_baseURL = baseURL ?? _getDefaultBaseURL(environment);
if (defaultHeaders != null) {
_defaultHeaders.addAll(defaultHeaders);
}
// Configure in C++ layer if available
try {
final lib = PlatformLoader.loadCommons();
final configureFn = lib.lookupFunction<
Int32 Function(Pointer<Utf8>, Pointer<Utf8>),
int Function(Pointer<Utf8>, Pointer<Utf8>)>('rac_http_configure');
final basePtr = (_baseURL ?? '').toNativeUtf8();
final keyPtr = (_apiKey ?? '').toNativeUtf8();
try {
final result = configureFn(basePtr, keyPtr);
if (result != RacResultCode.success) {
_logger.warning('HTTP configure failed', metadata: {'code': result});
}
} finally {
calloc.free(basePtr);
calloc.free(keyPtr);
}
} catch (e) {
_logger.debug('rac_http_configure not available: $e');
}
_isConfigured = true;
_logger.debug('HTTP configured', metadata: {'baseURL': _baseURL});
}