Serverpod constructor
Serverpod(
- List<
String> args, - DatabaseSerializationManager serializationManager,
- EndpointDispatch endpoints, {
- Directory? serverDirectory,
- ServerpodConfig? config,
- ServerpodConfig configOverride()?,
- AuthenticationHandler? authenticationHandler,
- HealthCheckHandler? healthCheckHandler,
- HealthConfig? healthConfig,
- Headers? httpResponseHeaders,
- Headers? httpOptionsResponseHeaders,
- SecurityContextConfig? securityContextConfig,
- ExperimentalFeatures? experimentalFeatures,
- RuntimeParametersListBuilder? runtimeParametersBuilder,
Creates a new Serverpod.
Experimental features
Features marked as experimental are new and the API and names may change from one minor release to another.
Implementation
Serverpod(
List<String> args,
this.serializationManager,
this.endpoints, {
Directory? serverDirectory,
ServerpodConfig? config,
ServerpodConfig Function(ServerpodConfig)? configOverride,
this.authenticationHandler,
this.healthCheckHandler,
HealthConfig? healthConfig,
Headers? httpResponseHeaders,
Headers? httpOptionsResponseHeaders,
SecurityContextConfig? securityContextConfig,
ExperimentalFeatures? experimentalFeatures,
this.runtimeParametersBuilder,
}) : serverDirectory = Directory(
p.normalize(p.absolute((serverDirectory ?? Directory.current).path)),
),
httpResponseHeaders = httpResponseHeaders ?? _defaultHttpResponseHeaders,
httpOptionsResponseHeaders =
httpOptionsResponseHeaders ?? _defaultHttpOptionsResponseHeaders,
_configOverride = configOverride,
_securityContextConfig = securityContextConfig,
_healthConfig = healthConfig ?? const HealthConfig(),
_experimental = ExperimentalApi._(
config: config,
experimentalFeatures: experimentalFeatures,
) {
try {
_initializeServerpod(
args,
config: config,
);
} on ExitException catch (e) {
// Construction failed - the object is half-initialized so we
// can't let control return to the caller. Emit the message
// synchronously and exit before any async drain could return.
if (e.message.isNotEmpty) {
stderr.writeln(e.message);
}
exit(e.exitCode);
} catch (e, stackTrace) {
stderr.writeln('Error initializing Serverpod: $e');
stderr.writeln(stackTrace);
exit(1);
}
}