feat: refactor HTTP client setup for Github and Forgejo services

- Centralized HTTP client configuration for `GithubService` and `ForgejoService` using `AddHttpClient`.
- Enhanced maintainability by moving Forgejo token and base URL setup into DI-configured HTTP clients.
- Fixed `forgejoInstance` validation logic and adjusted release selection to prioritize the first non-prerelease.
This commit is contained in:
mahdium committed 2026-11-04 16:55:58 +03:30
1 parent 7ac8a5af62
commit 3b644de2d5
5 files changed
+20 -15

No files matched your search

-2
View File
@@ -20,7 +20,6 @@ public class ForgejoService(HttpClient httpClient, AppConfig config, ILogger<For
HttpMethod.Post,
new Uri($"{config.ForgejoInstacne}/api/v1/repos/{owner}/{repo}/releases"));
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
request.Headers.Authorization = new AuthenticationHeaderValue("token", config.ForgejoToken);
using var response = await httpClient.SendAsync(request, token);
response.EnsureSuccessStatusCode();
@@ -79,7 +78,6 @@ public class ForgejoService(HttpClient httpClient, AppConfig config, ILogger<For
HttpMethod.Post,
new Uri($"{config.ForgejoInstacne}/api/v1/repos/{owner}/{repo}/releases/{releaseId}/assets"));
request.Content = formData;
request.Headers.Authorization = new AuthenticationHeaderValue("token", config.ForgejoToken);
using var response = await httpClient.SendAsync(
request, HttpCompletionOption.ResponseHeadersRead, token);