serving static method

ServerAdapter serving(
  1. ServerAdapter? server,
  2. HttpServer bound
)

The adapter that serves bound, a server that server opened. For a CustomServer: the native one for a native server, the adapter of an AdaptedServer (eg. a DoxHttpServer), else the plain dart:io one.

Implementation

static ServerAdapter serving(ServerAdapter? server, HttpServer bound) {
  if (server is! CustomServer) return server ?? const NativeServerAdapter();
  return switch (bound) {
    NativeHttpServer() => const NativeServerAdapter(),
    AdaptedServer(:ServerAdapter serverAdapter) => serverAdapter,
    _ => const IoServerAdapter(),
  };
}