-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added http client handlers * added obsolete * .net 8 * Update ci.yml * Update release-preview.yml * Update release.yml * fix httpclient bug * transient httpclienthandlers * add SendAsync retryPolicy + update readme * fix * update readme * add handlers constructor logging * review * add named and typed http clients * fix readme * fix 5xx logging --------- Co-authored-by: Станислав Терещенков <tereschenkov.s@ati.su>
- Loading branch information
Showing
26 changed files
with
813 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
ATI.Services.Common/Http/Extensions/HttpClientBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using ATI.Services.Common.Http.HttpHandlers; | ||
using ATI.Services.Common.Options; | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace ATI.Services.Common.Http.Extensions; | ||
|
||
[PublicAPI] | ||
public static class HttpClientBuilderExtensions | ||
{ | ||
public static IHttpClientBuilder WithProxyFields<TServiceOptions>(this IHttpClientBuilder httpClientBuilder) | ||
where TServiceOptions : BaseServiceOptions | ||
{ | ||
httpClientBuilder.Services.AddTransient<HttpProxyFieldsHandler<TServiceOptions>>(); | ||
|
||
return httpClientBuilder | ||
.AddHttpMessageHandler<HttpProxyFieldsHandler<TServiceOptions>>(); | ||
} | ||
|
||
public static IHttpClientBuilder WithLogging<TServiceOptions>(this IHttpClientBuilder httpClientBuilder) | ||
where TServiceOptions : BaseServiceOptions | ||
{ | ||
httpClientBuilder.Services.AddTransient<HttpLoggingHandler<TServiceOptions>>(); | ||
|
||
return httpClientBuilder | ||
.AddHttpMessageHandler<HttpLoggingHandler<TServiceOptions>>(); | ||
} | ||
|
||
public static IHttpClientBuilder WithMetrics<TServiceOptions>(this IHttpClientBuilder httpClientBuilder) | ||
where TServiceOptions : BaseServiceOptions | ||
{ | ||
httpClientBuilder.Services.AddTransient<HttpMetricsHandler<TServiceOptions>>(); | ||
|
||
return httpClientBuilder | ||
.AddHttpMessageHandler<HttpMetricsHandler<TServiceOptions>>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.