go method

Future<Response> go({
  1. ResponseHook? onSuccess,
  2. ResponseHook? onFailure,
  3. bool throwOnErr = false,
  4. Map<String, dynamic> pathParams = const {},
})

Implementation

Future<ht.Response> go(
    {ResponseHook? onSuccess,
    ResponseHook? onFailure,
    bool throwOnErr = false,
    Map<String, dynamic> pathParams = const {}}) async {
  final cloned = clone();
  cloned.pathParams(pathParams);
  ht.Response ret = await cloned._send();
  for (After func in cloned.getAfter) {
    ht.Response? res = await func(ret);
    if (res != null) {
      ret = res;
    }
  }

  if (onSuccess != null) {
    if (ret.isSuccess) {
      await onSuccess(ret);
    }
  }

  if (onFailure != null) {
    if (ret.isFailure) {
      await onFailure(ret);
    }
  }

  if (throwOnErr) {
    if (ret.isFailure) {
      throw ret;
    }
  }

  return ret;
}