Mako/Util/Objects.cs
/// <summary>
///     Returns <see cref="Result{T}.Failure" /> if the status code does not indicating success
/// </summary>
/// <param name="httpClient"></param>
/// <param name="url"></param>
/// <param name="exceptionSelector"></param>
/// <returns></returns>
Returns  if the status code does not indicating success
Returns if the status code does not indicating success
public static async Task<Result<string>> GetStringResultAsync(this HttpClient httpClient, string url, Func<HttpResponseMessage, Task<Exception>>? exceptionSelector = null)
        {
            var responseMessage = await httpClient.GetAsync(url).ConfigureAwait(false);
            return !responseMessage.IsSuccessStatusCode ? Result<string>.OfFailure(exceptionSelector is { } selector ? await selector.Invoke(responseMessage).ConfigureAwait(false) : null) : Result<string>.OfSuccess(await responseMessage.Content.ReadAsStringAsync());
        }
public static async Task < Result < string > > GetStringResultAsync ( this HttpClient httpClient , string url , Func < HttpResponseMessage , Task < Exception > > ? exceptionSelector = null ) { var responseMessage = await httpClient . GetAsync ( url ) . ConfigureAwait ( false ) ; return ! responseMessage . IsSuccessStatusCode ? Result < string > . OfFailure ( exceptionSelector is { } selector ? await selector . Invoke ( responseMessage ) . ConfigureAwait ( false ) : null ) : Result < string > . OfSuccess ( await responseMessage . Content . ReadAsStringAsync ( ) ) ; }
Returns  if the status code does not indicating success
Returns if the status code does not indicating success
None
HttpClient
this
url
string
None
exceptionSelector
Func<HttpResponseMessage, Task<Exception>>?
None
httpClient
None