Skip to content

Commit

Permalink
set dapr-api-token to healthz requests when needed
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com>
  • Loading branch information
famarting committed Sep 7, 2023
1 parent fd7168f commit e53483c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Dapr.Client/DaprClientGrpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1743,6 +1743,12 @@ public override async Task<bool> CheckHealthAsync(CancellationToken cancellation
{
var path = "/v1.0/healthz";
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(this.httpEndpoint, path));

if (this.apiTokenHeader is not null)
{
request.Headers.Add(this.apiTokenHeader.Value.Key, this.apiTokenHeader.Value.Value);

Check warning on line 1749 in src/Dapr.Client/DaprClientGrpc.cs

View check run for this annotation

Codecov / codecov/patch

src/Dapr.Client/DaprClientGrpc.cs#L1749

Added line #L1749 was not covered by tests
}

try
{
using var response = await this.httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
Expand All @@ -1759,6 +1765,12 @@ public override async Task<bool> CheckOutboundHealthAsync(CancellationToken canc
{
var path = "/v1.0/healthz/outbound";
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(this.httpEndpoint, path));

if (this.apiTokenHeader is not null)
{
request.Headers.Add(this.apiTokenHeader.Value.Key, this.apiTokenHeader.Value.Value);

Check warning on line 1771 in src/Dapr.Client/DaprClientGrpc.cs

View check run for this annotation

Codecov / codecov/patch

src/Dapr.Client/DaprClientGrpc.cs#L1771

Added line #L1771 was not covered by tests
}

try
{
using var response = await this.httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
Expand Down

0 comments on commit e53483c

Please sign in to comment.