Skip to content

Commit

Permalink
set dapr-api-token to healthz requests when needed (dapr#1145)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com>
Co-authored-by: Yaron Schneider <schneider.yaron@live.com>
  • Loading branch information
famarting and yaron2 committed Sep 7, 2023
1 parent 87329f6 commit 99d874a
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);
}

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);
}

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

0 comments on commit 99d874a

Please sign in to comment.