Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add override SendAsync with HttpResponseMessage #22

Merged
merged 6 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ATI.Services.Consul/ATI.Services.Consul.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="atisu.services.common" Version="12.3.0" />
<PackageReference Include="atisu.services.common" Version="13.2.1" />
<PackageReference Include="Consul" Version="1.6.10.9" />
</ItemGroup>
</Project>
31 changes: 31 additions & 0 deletions ATI.Services.Consul/ConsulMetricsHttpClientWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,37 @@ public Task<OperationResult<string>> PatchAsync(

#endregion

#region Send

public async Task<OperationResult<HttpResponseMessage<TResponse>>> SendAsync<TBody, TResponse>(
HttpMethod methodName,
string url,
TBody body,
string metricName,
Dictionary<string, string> headers = null,
string urlTemplate = null,
string[] additionalLabels = null)
{
using var _ =
_metricsTracingFactory.CreateLoggingMetricsTimer(metricName,
$"{methodName}:{urlTemplate ?? url}",
additionalLabels);
{
try
{
var serviceAddress = await _serviceAddress.ToHttpAsync();
return await _clientWrapper.SendAsync<TBody, TResponse>(new Uri(new Uri(serviceAddress),url), metricName, body, headers, methodName);
}
catch (Exception e)
{
_logger.LogWithObject(_serviceOptions.LogLevelOverride(LogLevel.Error), e);
return new(ActionStatus.InternalServerError);
}
}
}

#endregion

private async Task<OperationResult<T>> SendAsync<T>(string url,
string urlTemplate,
string metricName,
Expand Down
Loading