mudancinhas
All checks were successful
Mindforge API Build and Deploy / Build Mindforge API Image (push) Successful in 2m12s
Mindforge API Build and Deploy / Deploy Mindforge API (internal) (push) Successful in 8s
Mindforge Web Build and Deploy (internal) / Build Mindforge Web Image (push) Successful in 3m41s
Mindforge Web Build and Deploy (internal) / Deploy Mindforge Web (internal) (push) Successful in 8s
All checks were successful
Mindforge API Build and Deploy / Build Mindforge API Image (push) Successful in 2m12s
Mindforge API Build and Deploy / Deploy Mindforge API (internal) (push) Successful in 8s
Mindforge Web Build and Deploy (internal) / Build Mindforge Web Image (push) Successful in 3m41s
Mindforge Web Build and Deploy (internal) / Deploy Mindforge Web (internal) (push) Successful in 8s
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Mindforge.API.Services
|
||||
{
|
||||
public class GiteaService : IGiteaService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly string _baseUrl = string.Empty;
|
||||
private readonly string _owner = string.Empty;
|
||||
private readonly string _repo = string.Empty;
|
||||
@@ -21,9 +21,9 @@ namespace Mindforge.API.Services
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
public GiteaService(HttpClient httpClient, IConfiguration configuration)
|
||||
public GiteaService(IHttpClientFactory httpClientFactory, IConfiguration configuration)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_httpClientFactory = httpClientFactory;
|
||||
|
||||
var repoUrl = configuration["GITEA_REPO_URL"];
|
||||
var token = configuration["GITEA_ACCESS_TOKEN"];
|
||||
@@ -78,7 +78,8 @@ namespace Mindforge.API.Services
|
||||
$"{_baseUrl}/api/v1/repos/{_owner}/{_repo}/raw/{path}?ref=master");
|
||||
request.Headers.Add("Authorization", $"token {_token}");
|
||||
|
||||
var response = await _httpClient.SendAsync(request);
|
||||
var httpClient = _httpClientFactory.CreateClient();
|
||||
var response = await httpClient.SendAsync(request);
|
||||
if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
throw new UserException($"File not found in repository: {path}");
|
||||
|
||||
@@ -90,9 +91,10 @@ namespace Mindforge.API.Services
|
||||
{
|
||||
EnsureConfigured();
|
||||
|
||||
var httpClient = _httpClientFactory.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, $"{_baseUrl}{endpoint}");
|
||||
request.Headers.Add("Authorization", $"token {_token}");
|
||||
var response = await _httpClient.SendAsync(request);
|
||||
var response = await httpClient.SendAsync(request);
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user