Skip to content

Commit

Permalink
Configure await false
Browse files Browse the repository at this point in the history
  • Loading branch information
queil committed Jun 13, 2022
1 parent 242059a commit 08ecbb9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public async ValueTask<AuthorizeResult> AuthorizeAsync(
IOpaService? opaService = context.Services.GetRequiredService<IOpaService>();
IOpaDecision? opaDecision = context.Services.GetRequiredService<IOpaDecision>();
IOpaQueryRequestFactory? factory = context.Services.GetRequiredService<IOpaQueryRequestFactory>();

ResponseBase? response = await opaService.QueryAsync(directive.Policy ?? string.Empty, factory.CreateRequest(context, directive), context.RequestAborted);

ResponseBase? response = await opaService.QueryAsync(directive.Policy ?? string.Empty,
factory.CreateRequest(context, directive), context.RequestAborted).ConfigureAwait(false);
return opaDecision.Map(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ internal static HttpContent ToJsonContent(this QueryRequest request, JsonSeriali
internal static async Task<QueryResponse?> QueryResponseFromJsonAsync(this HttpContent content, JsonSerializerOptions options, CancellationToken token)
{
#if NET6_0
return await content.ReadFromJsonAsync<QueryResponse>(options, token);
return await content.ReadFromJsonAsync<QueryResponse>(options, token).ConfigureAwait(false);
#else
return await JsonSerializer.DeserializeAsync<QueryResponse>(await content.ReadAsStreamAsync(), options, token);
return await JsonSerializer.DeserializeAsync<QueryResponse>(await content.ReadAsStreamAsync().ConfigureAwait(false), options, token).ConfigureAwait(false);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public OpaService(HttpClient httpClient, OpaOptions options)
if (policyPath is null) throw new ArgumentNullException(nameof(policyPath));
if (request is null) throw new ArgumentNullException(nameof(request));

HttpResponseMessage response = await _httpClient.PostAsync(policyPath, request.ToJsonContent(_options.JsonSerializerOptions), token);
HttpResponseMessage response = await _httpClient.PostAsync(policyPath, request.ToJsonContent(_options.JsonSerializerOptions), token).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
QueryResponse? result = await response.Content.QueryResponseFromJsonAsync(_options.JsonSerializerOptions, token);
QueryResponse? result = await response.Content.QueryResponseFromJsonAsync(_options.JsonSerializerOptions, token).ConfigureAwait(false);
return result switch
{
{ Result: null } when policyPath.Equals(string.Empty) => NoDefaultPolicy.Response,
Expand Down

0 comments on commit 08ecbb9

Please sign in to comment.