newApi method
Implementation
String newApi({
required String newApiHost,
required List<String>
shouldChangeApiHosts, // 允许 mock api 的 host,即使同一环境也可能有多个网络库,多种host
}) {
String apiPath; //api path
bool hasHttpPrefix = this.startsWith(RegExp(r'https?:'));
if (hasHttpPrefix) {
apiPath = this.removeStartSpecialString(shouldChangeApiHosts);
if (apiPath == this) {
print('获取api path失败$this, 无法mock, 仍然是请求原地址');
return this;
}
} else {
apiPath = this;
}
String newApi = newApiHost.env_appendPathString(this);
//print('mock newApi = ${newApi}');
return newApi;
}