fix: response leak, TrackProxyController rename, restore api.json load
This commit is contained in:
@@ -10,13 +10,13 @@ namespace DeepDrftPublic.Controllers;
|
|||||||
/// named clients — no proxy hop needed on the server side.
|
/// named clients — no proxy hop needed on the server side.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/[controller]")]
|
[Route("api/track")]
|
||||||
public class TrackController : ControllerBase
|
public class TrackProxyController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly HttpClient _upstream;
|
private readonly HttpClient _upstream;
|
||||||
private readonly ILogger<TrackController> _logger;
|
private readonly ILogger<TrackProxyController> _logger;
|
||||||
|
|
||||||
public TrackController(IHttpClientFactory httpClientFactory, ILogger<TrackController> logger)
|
public TrackProxyController(IHttpClientFactory httpClientFactory, ILogger<TrackProxyController> logger)
|
||||||
{
|
{
|
||||||
_upstream = httpClientFactory.CreateClient("DeepDrft.API");
|
_upstream = httpClientFactory.CreateClient("DeepDrft.API");
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@@ -103,6 +103,7 @@ public class TrackController : ControllerBase
|
|||||||
Response.ContentLength = contentLength.Value;
|
Response.ContentLength = contentLength.Value;
|
||||||
|
|
||||||
var stream = await upstream.Content.ReadAsStreamAsync(ct);
|
var stream = await upstream.Content.ReadAsStreamAsync(ct);
|
||||||
|
HttpContext.Response.RegisterForDispose(upstream);
|
||||||
return File(stream, contentType, enableRangeProcessing: false);
|
return File(stream, contentType, enableRangeProcessing: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,16 @@ using DeepDrftPublic;
|
|||||||
using MudBlazor.Services;
|
using MudBlazor.Services;
|
||||||
using DeepDrftPublic.Components;
|
using DeepDrftPublic.Components;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
|
using NetBlocks.Utilities.Environment;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add MudBlazor services
|
// Add MudBlazor services
|
||||||
builder.Services.AddMudServices();
|
builder.Services.AddMudServices();
|
||||||
|
|
||||||
|
var apiPath = CredentialTools.ResolvePathOrThrow("api", "environment/api.json");
|
||||||
|
builder.Configuration.AddJsonFile(apiPath, optional: false, reloadOnChange: false);
|
||||||
|
|
||||||
var contentApiUrl = builder.Configuration["ApiUrls:ContentApi"] ?? throw new Exception("Content API URL is not configured");
|
var contentApiUrl = builder.Configuration["ApiUrls:ContentApi"] ?? throw new Exception("Content API URL is not configured");
|
||||||
var sqlApiUrl = builder.Configuration["ApiUrls:SqlApi"] ?? throw new Exception("ApiUrls:SqlApi is not configured");
|
var sqlApiUrl = builder.Configuration["ApiUrls:SqlApi"] ?? throw new Exception("ApiUrls:SqlApi is not configured");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user