Use cancellation in more places

This commit is contained in:
Archi
2023-11-14 21:20:51 +01:00
parent ac9d4a7783
commit 3f04144e41
3 changed files with 19 additions and 14 deletions

View File

@@ -21,6 +21,7 @@
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using ArchiSteamFarm.Core;
using ArchiSteamFarm.IPC.Controllers.Api;
@@ -45,7 +46,9 @@ public sealed class CatController : ArchiController {
throw new InvalidOperationException(nameof(ASF.WebBrowser));
}
Uri? url = await CatAPI.GetRandomCatURL(ASF.WebBrowser).ConfigureAwait(false);
CancellationToken cancellationToken = HttpContext.RequestAborted;
Uri? url = await CatAPI.GetRandomCatURL(ASF.WebBrowser, cancellationToken).ConfigureAwait(false);
return url != null ? Ok(new GenericResponse<Uri>(url)) : StatusCode((int) HttpStatusCode.ServiceUnavailable, new GenericResponse(false));
}