Skip to content

Commit

Permalink
feat: fix health check to use full uri
Browse files Browse the repository at this point in the history
  • Loading branch information
hermogenes committed Jul 14, 2024
1 parent befb411 commit a8096e4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/LibSql.Http.Client/LibSqlHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ namespace LibSql.Http.Client;
public sealed class LibSqlHttpClient : ILibSqlHttpClient
{
private const string PipelineV3Path = "/v3/pipeline";
private const string HealthPath = "/health";
private readonly AuthenticationHeaderValue? _authHeaderValue;

private readonly HttpClient _httpClient;
private readonly Uri _pipelineUri;
private readonly Uri _baseUri;
private readonly string _healthUri;

/// <summary>
/// Creates a new instance of <see cref="LibSqlHttpClient" />.
Expand Down Expand Up @@ -71,7 +72,7 @@ public LibSqlHttpClient(HttpClient httpClient, Uri? url = null, string? authToke
"URL not set. Please provide a URL either in the constructor or as a parameter or via HttpClient.BaseAddress.");

_pipelineUri = new Uri(url, PipelineV3Path);
_baseUri = url;
_healthUri = new Uri(url, HealthPath).ToString();

_httpClient = httpClient;

Expand Down Expand Up @@ -192,7 +193,7 @@ public Task<IResultReader> QueryMultipleAsync(
/// <inheritdoc />
public async Task<bool> HealthCheckAsync(CancellationToken cancellationToken = default)
{
var res = await _httpClient.GetAsync("/health", HttpCompletionOption.ResponseHeadersRead, cancellationToken);
using var res = await _httpClient.GetAsync(_healthUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken);

return res.IsSuccessStatusCode;
}
Expand Down

0 comments on commit a8096e4

Please sign in to comment.