Universal.Operative.Sdk.Http
1.3.0
See the version list below for details.
dotnet add package Universal.Operative.Sdk.Http --version 1.3.0
NuGet\Install-Package Universal.Operative.Sdk.Http -Version 1.3.0
<PackageReference Include="Universal.Operative.Sdk.Http" Version="1.3.0" />
<PackageVersion Include="Universal.Operative.Sdk.Http" Version="1.3.0" />
<PackageReference Include="Universal.Operative.Sdk.Http" />
paket add Universal.Operative.Sdk.Http --version 1.3.0
#r "nuget: Universal.Operative.Sdk.Http, 1.3.0"
#:package Universal.Operative.Sdk.Http@1.3.0
#addin nuget:?package=Universal.Operative.Sdk.Http&version=1.3.0
#tool nuget:?package=Universal.Operative.Sdk.Http&version=1.3.0
About
Universal.Operative.Sdk.Http adds HttpServiceClientProxyTool<TServiceClient, TArgs>, a Universal.Operative.Sdk.Tools.HttpProxyTool<TArgs> that sends its request through an existing Universal.Common.Net.Http.HttpServiceClient instead of a plain HttpClient.
Use this instead of Universal.Operative.Sdk.Tools.HttpClientProxyTool<TArgs> when a HttpServiceClient for the target API already exists (and is possibly used outside the tool-call path too) — auth injection and success/failure handling then live once, in that HttpServiceClient's own PreProcessHttpRequestMessageAsync/HandleSuccessStatusCodeAsync/HandleNonSuccessStatusCodeAsync overrides, rather than being re-implemented on the tool.
How to Use
Installation
dotnet add package Universal.Operative.Sdk.Http
Usage
using Universal.Common.Net.Http;
using Universal.Operative.Sdk.Http;
public sealed class ExampleServiceClient : HttpServiceClient
{
private readonly string _token;
public ExampleServiceClient(string token) => _token = token;
protected override Task PreProcessHttpRequestMessageAsync(HttpRequestMessage request, CancellationToken ct)
{
request.Headers.Authorization = new("Bearer", _token);
return Task.CompletedTask;
}
}
public sealed class ExampleTool(ExampleServiceClient client) : HttpServiceClientProxyTool<ExampleServiceClient, ExampleTool.Args>
{
protected override ExampleServiceClient ServiceClient { get; } = client;
public override string Name => "example";
public override ToolDefinition Definition { get; } = /* ... */;
protected override Task<HttpRequestMessage> BuildRequestAsync(Args args, CancellationToken ct)
=> Task.FromResult(new HttpRequestMessage(new HttpMethod(args.Method), $"https://api.example.com{args.Path}"));
public sealed record Args(string Method, string Path);
}
BuildRequestAsync only needs to shape the request (URI, method, body) — auth is applied by ServiceClient itself before the send, and FormatResponseAsync (inherited from HttpProxyTool<TArgs>, override to customize) turns the response into a ToolResult afterward.
License
Free for noncommercial use under the Universal.Operative Noncommercial License. Source is closed; commercial use requires a separate license from Andrew Ong.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. 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 is compatible. 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. |
-
net10.0
- Universal.Common.Net.Http (>= 5.2.0)
- Universal.Operative.Sdk (>= 5.2.0)
-
net8.0
- Universal.Common.Net.Http (>= 5.2.0)
- Universal.Operative.Sdk (>= 5.2.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Universal.Operative.Sdk.Http:
| Package | Downloads |
|---|---|
|
Universal.Operative.Sdk.Slack
Slack Web API tool for the Universal.Operative.Sdk. |
|
|
Universal.Operative.Sdk.Discord
Discord REST API tool for the Universal.Operative.Sdk. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Multitargets .NET 8 and .NET 10.