Add initial project structure and configuration files for Marechai.App

This commit is contained in:
2025-11-14 01:50:56 +00:00
parent f85dc22bf6
commit cf24356030
50 changed files with 1875 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Uno.Extensions.Logging;
namespace Marechai.App.Services.Endpoints;
internal class DebugHttpHandler : DelegatingHandler
{
private readonly ILogger _logger;
public DebugHttpHandler(ILogger<DebugHttpHandler> logger, HttpMessageHandler? innerHandler = null)
: base(innerHandler ?? new HttpClientHandler())
{
_logger = logger;
}
protected async override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
var response = await base.SendAsync(request, cancellationToken);
#if DEBUG
if (!response.IsSuccessStatusCode)
{
_logger.LogDebugMessage("Unsuccessful API Call");
if (request.RequestUri is not null)
{
_logger.LogDebugMessage($"{request.RequestUri} ({request.Method})");
}
foreach ((var key, var values) in request.Headers.ToDictionary(x => x.Key, x => string.Join(", ", x.Value)))
{
_logger.LogDebugMessage($"{key}: {values}");
}
var content = request.Content is not null ? await request.Content.ReadAsStringAsync() : null;
if (!string.IsNullOrEmpty(content))
{
_logger.LogDebugMessage(content);
}
// Uncomment to automatically break when an API call fails while debugging
// System.Diagnostics.Debugger.Break();
}
#endif
return response;
}
}