GitHub·· 6 天前AI 评分10
Soenneker.OpenHands.HttpClients:面向 OpenHands Cloud API 的缓存 HttpClient
soenneker/soenneker.openhands.httpclients
AI 导读
Soenneker.OpenHands.HttpClients 发布,提供为 OpenHands Cloud API 配置的缓存 HttpClient,内置 bearer 认证。
正文
Provides a cached HttpClient configured for the OpenHands Cloud API, including bearer authentication.
Install
dotnet add package Soenneker.OpenHands.HttpClients
Configuration
{
"OpenHands": {
"ApiKey": "your-api-key"
}
}OpenHands:ClientBaseUrl, OpenHands:AuthHeaderName, and OpenHands:AuthHeaderValueTemplate can override the defaults.
Usage
using Soenneker.OpenHands.HttpClients.Abstract; using Soenneker.OpenHands.HttpClients.Registrars; services.AddOpenHandsOpenApiHttpClientAsSingleton(); IOpenHandsOpenApiHttpClient provider = serviceProvider .GetRequiredService<IOpenHandsOpenApiHttpClient>(); HttpClient client = await provider.Get(cancellationToken); HttpResponseMessage response = await client.GetAsync( "api/v1/app-conversations/search?limit=20", cancellationToken); response.EnsureSuccessStatusCode();
The provider owns its cached client. Disposing the provider removes and disposes that client. Scoped registration gives each provider instance its own cached client.
来源:GitHub · github.com