resolveFunctionUrl static method
String
resolveFunctionUrl(
{ - required String functionName,
- required String productionUrl,
- required bool isRelease,
- required bool usesEmulators,
- String host = '127.0.0.1',
- int port = 5001,
- String projectId = 'demo-emxi-local',
- String region = 'us-central1',
})
Implementation
@visibleForTesting
static String resolveFunctionUrl({
required String functionName,
required String productionUrl,
required bool isRelease,
required bool usesEmulators,
String host = '127.0.0.1',
int port = 5001,
String projectId = 'demo-emxi-local',
String region = 'us-central1',
}) {
if (isRelease) return productionUrl;
if (!usesEmulators) {
throw StateError(
'Cloud Functions productivas bloqueadas en debug/profile. '
'Inicia Firebase Functions Emulator y usa '
'USE_FIREBASE_EMULATORS=true.',
);
}
if (functionName.isEmpty ||
host.isEmpty ||
port <= 0 ||
projectId.isEmpty ||
region.isEmpty) {
throw StateError(
'Configuracion invalida del Functions Emulator para "$functionName".',
);
}
return Uri(
scheme: 'http',
host: host,
port: port,
pathSegments: [projectId, region, functionName],
).toString();
}