serve static method
Future<HubAdminServer>
serve({
- required CoordinationHub hub,
- required String token,
- InternetAddress? address,
- int port = 0,
Starts the admin server.
token is required and compared in constant time. address defaults to
loopback and should stay there.
Implementation
static Future<HubAdminServer> serve({
required CoordinationHub hub,
required String token,
InternetAddress? address,
int port = 0,
}) async {
if (token.isEmpty) {
throw ArgumentError.value('<redacted>', 'token', 'must not be empty');
}
final server = await HttpServer.bind(
address ?? InternetAddress.loopbackIPv4,
port,
);
final admin = HubAdminServer._(server, hub, token);
unawaited(admin._accept());
logger.info(
'Hub admin listening on http://${server.address.host}:'
'${server.port}',
);
return admin;
}