Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/LinkAce.NET/LinkAceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ namespace LinkAce.NET;
public class LinkAceClient
{
private static string? _apiUrl;
private static HttpClient _client = new();
private static HttpClient _client;
/// <summary>
/// Initializes a new instance of the <see cref="LinkAceClient" /> class with the specified URL and HTTP client.
/// </summary>
/// <param name="linkAceUrl">The base URL of the LinkAce.NET instance.</param>
/// <param name="httpClient">The HTTP client to use for requests.</param>
[Obsolete("Use the constructor with the API token instead.")]
public LinkAceClient(string linkAceUrl, HttpClient httpClient)
{
_apiUrl = $"{linkAceUrl}/api/v1";
Expand All @@ -32,10 +33,12 @@ public LinkAceClient(string linkAceUrl, HttpClient httpClient)
/// </summary>
/// <param name="linkAceUrl">The base URL of the LinkAce.NET instance.</param>
/// <param name="apiToken">The API token for authentication.</param>
public LinkAceClient(string linkAceUrl, string apiToken)
/// <param name="client">The HTTP client to use for requests.</param>
public LinkAceClient(string linkAceUrl, string apiToken, HttpClient? client = null)
{
_apiUrl = $"{linkAceUrl}/api/v1";
// Setup HttpClient
_client = client ?? new HttpClient();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json));
_client.DefaultRequestHeaders.UserAgent.Add(Meta.UserAgent);
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiToken);
Expand Down