createAlphaXClient function

AlphaXClient createAlphaXClient({
  1. Iterable<AlphaXMiddleware> middleware = const <AlphaXMiddleware>[],
  2. bool withCredentials = false,
})

Creates one AlphaX client backed by browser Fetch.

Browser TLS, proxy routing, CORS, redirects, connection reuse, and negotiated protocol remain browser-owned. withCredentials controls the browser Fetch credential mode; it does not provide native credential or cookie behavior.

Implementation

AlphaXClient createAlphaXClient({
  Iterable<AlphaXMiddleware> middleware = const <AlphaXMiddleware>[],
  bool withCredentials = false,
}) {
  final transport = WebFetchTransport(withCredentials: withCredentials);
  try {
    return AlphaXClient(
      transport: transport,
      middleware: middleware,
    );
  } catch (error, stackTrace) {
    unawaited(transport.close());
    Error.throwWithStackTrace(error, stackTrace);
  }
}