Skip to content

About

A thread-safe singleton HttpClient for CloudAgents's OpenAPI integration.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Soenneker.Cursor.CloudAgents.HttpClients

Provides a cached HttpClient configured for Cursor's Cloud Agents API with bearer authentication.

Installation

dotnet add package Soenneker.Cursor.CloudAgents.HttpClients

Configuration

{
  "Cursor": {
    "ApiKey": "your-cursor-api-key"
  }
}

The default base address is https://api.cursor.com/, and requests send Authorization: Bearer <ApiKey>. Override these with CloudAgents:ClientBaseUrl, CloudAgents:AuthHeaderName, and CloudAgents:AuthHeaderValueTemplate; the value template uses {token} as the API-key placeholder.

Registration and usage

using Soenneker.Cursor.CloudAgents.HttpClients.Abstract;
using Soenneker.Cursor.CloudAgents.HttpClients.Registrars;

services.AddCursorCloudAgentsOpenApiHttpClientAsSingleton();

public sealed class CursorAccountReader(ICursorCloudAgentsOpenApiHttpClient clients)
{
    public async Task<HttpResponseMessage> Get(CancellationToken cancellationToken)
    {
        HttpClient client = await clients.Get(cancellationToken);
        return await client.GetAsync("v1/me", cancellationToken);
    }
}

Get returns the same cached client for the provider's lifetime. The provider owns it, so callers should dispose response messages but not the returned HttpClient. Prefer the singleton registration for normal application use; the scoped registration creates a separately owned cache entry for each scope.

About

A thread-safe singleton HttpClient for CloudAgents's OpenAPI integration.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages