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
  • Loading branch information
famarting committed Sep 7, 2023
1 parent fd7168f commit 7bfc18c
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 7bfc18c

Please sign in to comment.