Skip to content

Commit 99d874a

Browse files
famartingyaron2
andauthored
set dapr-api-token to healthz requests when needed (#1145)
Signed-off-by: Fabian Martinez <[email protected]> Co-authored-by: Yaron Schneider <[email protected]>
1 parent 87329f6 commit 99d874a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: src/Dapr.Client/DaprClientGrpc.cs

+12
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,12 @@ public override async Task<bool> CheckHealthAsync(CancellationToken cancellation
17431743
{
17441744
var path = "/v1.0/healthz";
17451745
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(this.httpEndpoint, path));
1746+
1747+
if (this.apiTokenHeader is not null)
1748+
{
1749+
request.Headers.Add(this.apiTokenHeader.Value.Key, this.apiTokenHeader.Value.Value);
1750+
}
1751+
17461752
try
17471753
{
17481754
using var response = await this.httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
@@ -1759,6 +1765,12 @@ public override async Task<bool> CheckOutboundHealthAsync(CancellationToken canc
17591765
{
17601766
var path = "/v1.0/healthz/outbound";
17611767
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(this.httpEndpoint, path));
1768+
1769+
if (this.apiTokenHeader is not null)
1770+
{
1771+
request.Headers.Add(this.apiTokenHeader.Value.Key, this.apiTokenHeader.Value.Value);
1772+
}
1773+
17621774
try
17631775
{
17641776
using var response = await this.httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);

0 commit comments

Comments
 (0)