Tingle.Extensions.Http
4.11.0
See the version list below for details.
dotnet add package Tingle.Extensions.Http --version 4.11.0
NuGet\Install-Package Tingle.Extensions.Http -Version 4.11.0
<PackageReference Include="Tingle.Extensions.Http" Version="4.11.0" />
paket add Tingle.Extensions.Http --version 4.11.0
#r "nuget: Tingle.Extensions.Http, 4.11.0"
// Install Tingle.Extensions.Http as a Cake Addin #addin nuget:?package=Tingle.Extensions.Http&version=4.11.0 // Install Tingle.Extensions.Http as a Cake Tool #tool nuget:?package=Tingle.Extensions.Http&version=4.11.0
Tingle.Extensions.Http
This provides a lightweight abstraction around HttpClient
which can be used to build custom client with response wrapping semantics.
The default serialization is done using JSON (System.Text.Json
) but can be overridden to handle XML, SOAP, or any other formats including just changing the serializer to Newtonsoft.Json
.
Below we'll go through some examples of how the AbstractHttpApiClient
.
public class Account
{
public string? Id { get; set; }
public string? Name { get; set; }
}
public class MyServiceClient : AbstractApiClient<MyServiceClientOptions>
{
public MyServiceClient(HttpClient client, IOptions<MyServiceClientOptions> optionsAccessor) : base(client, optionsAccessor){}
public async Task<ResourceResponse<Account>> GetAccountAsync(string id, CancellationToken cancellationToken = default)
{
var uri = new Uri(BaseAddress, $"/v1/accounts/{id}");
var request = new HttpRequestMessage(HttpMethod.Get, uri);
return await SendAsync<Account>(request, cancellationToken);
}
// ...
}
public class MyServiceClientOptions : AbstractHttpApiClientOptions { }
Adding to services collection
In Program.cs
add the following code snippet:
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddHttpApiClient<MyServiceClient, MyServiceClientOptions>();
var host = builder.Build();
using var scope = host.Services.CreateScope();
var client = scope.ServiceProvider.GetRequiredService<MyServiceClient>();
var response = await client.GetAccountAsync("123456789");
response.EnsureSuccess(); // throws if not successful
response.EnsureHasResource(); // throws if the response body was empty (null resource)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Http (>= 8.0.0)
- System.Net.Http.Json (>= 8.0.0)
-
net7.0
- Microsoft.Extensions.Http (>= 8.0.0)
- System.Net.Http.Json (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.0)
- System.Net.Http.Json (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Tingle.Extensions.Http:
Package | Downloads |
---|---|
Tingle.Extensions.PushNotifications
Clients for sending push notifications via FCM, APNS etc |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.14.1 | 209 | 10/14/2024 |
4.14.0 | 381 | 9/16/2024 |
4.13.0 | 658 | 8/13/2024 |
4.12.0 | 187 | 8/7/2024 |
4.11.2 | 322 | 7/15/2024 |
4.11.1 | 391 | 6/26/2024 |
4.11.0 | 307 | 6/6/2024 |
4.10.1 | 120 | 6/5/2024 |
4.10.0 | 202 | 5/27/2024 |
4.9.0 | 314 | 5/16/2024 |
4.8.0 | 384 | 5/5/2024 |
4.7.0 | 581 | 3/25/2024 |
4.6.0 | 408 | 3/8/2024 |
4.5.0 | 1,500 | 11/22/2023 |
4.4.1 | 299 | 11/20/2023 |
4.4.0 | 243 | 11/15/2023 |
4.3.0 | 656 | 10/18/2023 |