APIServerConfig.fromArgs constructor
Implementation
factory APIServerConfig.fromArgs(List<String> args) {
var a = ArgsSimple.parse(args);
var development = a.flagOr('development', null);
var name = a.optionAsString('name');
var version = a.optionAsString('version');
var port = a.optionAsInt('port');
var securePort = a.optionAsInt('secure-port');
var address = a.optionAsString('address');
var letsEncrypt = a.flag('letsencrypt');
var letsEncryptProduction = letsEncrypt && a.flag('letsencrypt-production');
var allowRequestLetsEncryptCertificate =
letsEncrypt && a.flag('allow-request-letsencrypt-certificate');
var letsEncryptDirectory =
letsEncrypt ? a.optionAsDirectory('letsencrypt-directory') : null;
var hotReload = a.flag('hot-reload');
var totalWorkers = a.optionAsInt('total-workers');
var cookieless = a.flag('cookieless');
var useSessionID = a.flagOr('use-session-id', !cookieless)!;
var apiCacheControl = a.optionAsString('api-cache-control');
var staticFilesCacheControl =
a.optionAsString('static-files-cache-control');
var cacheStaticFilesResponses =
a.optionAsBool('cache-static-files-responses');
var staticFilesCacheMaxMemorySize =
a.optionAsInt('static-files-cache-max-memory-size');
var staticFilesCacheMaxContentLength =
a.optionAsInt('static-files-cache-max-content-length');
var logToConsole = a.flagOr('log-toConsole', null);
var logQueue = a.flagOr('log-queue', null);
var documentRoot = a.optionAsDirectory('document-root');
var domains = a.optionAsList('domains');
var apiConfigUri = a.optionAsString("api-config");
if (apiConfigUri == null) {
var arg0 = a.argumentAsString(0);
if (arg0 != null &&
(arg0.endsWith('.yml') ||
arg0.endsWith('.yaml') ||
arg0.endsWith('.json'))) {
apiConfigUri = arg0;
}
}
var apiConfig = apiConfigUri != null ? APIConfig.from(apiConfigUri) : null;
var serverResponseDelay = tryParseDuration(
a.optionAsString('server-response-delay') ??
apiConfig?.getPath<String>('server', 'response-delay'),
);
return APIServerConfig(
development: development ?? apiConfig?.development,
name: name,
version: version,
address: address,
port: port,
securePort: securePort,
documentRoot: documentRoot,
domains: domains,
letsEncryptDirectory: letsEncryptDirectory,
letsEncrypt: letsEncrypt,
letsEncryptProduction: letsEncryptProduction,
allowRequestLetsEncryptCertificate: allowRequestLetsEncryptCertificate,
hotReload: hotReload,
totalWorkers: totalWorkers,
cookieless: cookieless,
useSessionID: useSessionID,
apiCacheControl: apiCacheControl,
staticFilesCacheControl: staticFilesCacheControl,
cacheStaticFilesResponses: cacheStaticFilesResponses,
staticFilesCacheMaxMemorySize: staticFilesCacheMaxMemorySize,
staticFilesCacheMaxContentLength: staticFilesCacheMaxContentLength,
serverResponseDelay: serverResponseDelay,
apiConfig: apiConfig,
logToConsole: logToConsole,
logQueue: logQueue,
args: a,
);
}