checkHTTP method
Get statistic from server, check both http and https.
Implementation
Future<void> checkHTTP(WidgetRef ref, WorkerKey wKey) async {
try {
//
// > http
//
final host = wKey.activeHost;
final port = wKey.activePort;
var url = Uri.parse(
'http://$host:$port/stat',
);
ref.watch(_httpFuture(false).notifier).state = http.get(url);
//
// > https
//
url = Uri.parse(
'https://$host:$port/stat',
);
ref.watch(_httpFuture(true).notifier).state = http.get(url);
//
// > wait
//
await Future.wait([
ref.watch(_httpFuture(true)),
ref.watch(_httpFuture(false))
] as Iterable<Future>);
// ignore: avoid_catches_without_on_clauses
} catch (e) {
dev.log(e.toString());
}
}