Soda.Http
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Soda.Http --version 1.0.1
NuGet\Install-Package Soda.Http -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soda.Http" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soda.Http" Version="1.0.1" />
<PackageReference Include="Soda.Http" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soda.Http --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Soda.Http, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soda.Http@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soda.Http&version=1.0.1
#tool nuget:?package=Soda.Http&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Soda.Http
基于HttpClient封装的 Http 请求库。
用法
1 预载
预载配置并不是必须的,但是有助于我们进行一些通用基础设置,例如Headers、Accept、BaseUrl等等。
在AspNetCore中:
services.AddSodaHttp(opts =>
{
opts.BaseUrl = "http://localhost:8080/";
opts.Accept = new[]
{
"application/json",
"text/plain",
"*/*"
};
opts.EnableCompress = false;
opts.Headers = new[]{
("X-Ca-Test", "key")
};
});
较为通用的写法,程序构建时:
QSodaHttp.AddSodaHttp(opts =>
{
opts.BaseUrl = "http://localhost:8080/";
opts.Accept = new[]
{
"application/json",
"text/plain",
"*/*"
};
opts.EnableCompress = false;
opts.Headers = new[]{
("X-Ca-Test", "key")
};
})
2 全局配置 Authentication
有时需要全局配置 Authentication,如果在代码中请求中独立配置了 Authentication 则会覆盖全局 Authentication
QSodaHttp.InitAuthentication("Bearer", "Values");
如果你是塞到 Header 里的这种做法
QSodaHttp.InitHeader("X-Ca-Key", "Values");
3 Http 请求
3.1 QSodaHttp
var result = await QSodaHttp.Url($"http://localhost:8080/api/persion").GetAsync<object>();
| 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 was computed. 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 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Microsoft.Extensions.Options (>= 7.0.1)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.7 | 528 | 4/29/2023 |
| 1.0.6 | 390 | 4/2/2023 |
| 1.0.5 | 399 | 4/1/2023 |
| 1.0.5-preview | 313 | 3/27/2023 |
| 1.0.5-beta | 302 | 3/27/2023 |
| 1.0.4 | 406 | 3/25/2023 |
| 1.0.3 | 374 | 3/25/2023 |
| 1.0.2 | 377 | 3/25/2023 |
| 1.0.1 | 377 | 3/25/2023 |
| 1.0.0 | 350 | 3/25/2023 |