mergeEnv static method
Returns a new config with fields overridden by environment variables:
GO_HTTP_CONNECT_TIMEOUT(seconds)GO_HTTP_SEND_TIMEOUT(seconds)GO_HTTP_RECEIVE_TIMEOUT(seconds)GO_HTTP_MAX_REDIRECTSGO_HTTP_VERIFY("0"/"false"→false)
Implementation
static ClientConfig mergeEnv([ClientConfig? base]) {
var c = base ?? defaults;
final env = Platform.environment;
final connectStr = env['GO_HTTP_CONNECT_TIMEOUT'];
if (connectStr != null) {
final secs = int.tryParse(connectStr);
if (secs != null && secs > 0) {
c = c.copyWith(connectTimeout: Duration(seconds: secs));
}
}
final sendStr = env['GO_HTTP_SEND_TIMEOUT'];
if (sendStr != null) {
final secs = int.tryParse(sendStr);
if (secs != null && secs > 0) {
c = c.copyWith(sendTimeout: Duration(seconds: secs));
}
}
final recvStr = env['GO_HTTP_RECEIVE_TIMEOUT'];
if (recvStr != null) {
final secs = int.tryParse(recvStr);
if (secs != null && secs > 0) {
c = c.copyWith(receiveTimeout: Duration(seconds: secs));
}
}
final maxR = env['GO_HTTP_MAX_REDIRECTS'];
if (maxR != null) {
final n = int.tryParse(maxR);
if (n != null && n >= 0) {
c = c.copyWith(maxRedirects: n);
}
}
final verifyStr = env['GO_HTTP_VERIFY'];
if (verifyStr != null) {
c = c.copyWith(
verify: verifyStr == '0' || verifyStr == 'false' ? false : verifyStr,
);
}
return c;
}