Skip to content

Commit

Permalink
Merge pull request #2 from FizzBuzz791/fix/base-url
Browse files Browse the repository at this point in the history
fix: set base url in constructor
  • Loading branch information
FizzBuzz791 authored Aug 5, 2024
2 parents 337df8e + ae65dfa commit fbbaa98
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/HealthCheckService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

namespace NHealthCheck;

public class HealthCheckService(HttpClient httpClient) : IHealthCheckService
public class HealthCheckService : IHealthCheckService
{
private readonly HttpClient HttpClient = httpClient;
private readonly HttpClient HttpClient;

private string BaseUrl { get; set; } = "https://hc-ping.com";

public HealthCheckService(HttpClient httpClient)
{
HttpClient = httpClient;
HttpClient.BaseAddress = new Uri(BaseUrl);
}

public async Task<HttpResponseMessage> SuccessAsync(Guid uuid)
{
var url = $"{BaseUrl}/{uuid}";
Expand All @@ -24,7 +30,6 @@ private async Task<HttpResponseMessage> CallEndpoint(string url)
{
try
{
HttpClient.BaseAddress = new Uri(BaseUrl);
return await HttpClient.GetAsync(url);
}
catch (Exception ex)
Expand Down

0 comments on commit fbbaa98

Please sign in to comment.