Enhance service configuration and DI setup
Added `EnvelopeGenerator.WebUI.Client.Services` to the using directives. Registered `IHttpContextAccessor` to access HTTP context for request-specific information. Modified `HttpClient` setup to dynamically set the base address using the current request's host. Introduced several business services (`DocumentService`, `AuthService`, `AnnotationService`, `EnvelopeReceiverService`, `SignatureService`, `SignatureCacheService`, `AppVersionService`) to the service collection, indicating new features. Maintained existing YARP configuration. Noted the importance of DevExpress services for `DxPdfViewer`.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using EnvelopeGenerator.WebUI.Components;
|
using EnvelopeGenerator.WebUI.Components;
|
||||||
using DevExpress.Blazor;
|
using DevExpress.Blazor;
|
||||||
|
using EnvelopeGenerator.WebUI.Client.Services;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -12,12 +13,31 @@ builder.Services.AddRazorComponents()
|
|||||||
.AddInteractiveWebAssemblyComponents();
|
.AddInteractiveWebAssemblyComponents();
|
||||||
|
|
||||||
// HttpClient for server-side components (e.g., MainLayout with FontLoader)
|
// HttpClient for server-side components (e.g., MainLayout with FontLoader)
|
||||||
|
builder.Services.AddHttpContextAccessor();
|
||||||
builder.Services.AddScoped<HttpClient>(sp => {
|
builder.Services.AddScoped<HttpClient>(sp => {
|
||||||
var httpClientFactory = sp.GetRequiredService<IHttpClientFactory>();
|
var httpContextAccessor = sp.GetRequiredService<IHttpContextAccessor>();
|
||||||
return httpClientFactory.CreateClient();
|
var request = httpContextAccessor.HttpContext?.Request;
|
||||||
|
|
||||||
|
var httpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient();
|
||||||
|
|
||||||
|
if (request != null) {
|
||||||
|
// Set base address to current host (e.g., https://localhost:5131)
|
||||||
|
httpClient.BaseAddress = new Uri($"{request.Scheme}://{request.Host}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient;
|
||||||
});
|
});
|
||||||
builder.Services.AddHttpClient();
|
builder.Services.AddHttpClient();
|
||||||
|
|
||||||
|
// Business Services
|
||||||
|
builder.Services.AddScoped<DocumentService>();
|
||||||
|
builder.Services.AddScoped<AuthService>();
|
||||||
|
builder.Services.AddScoped<AnnotationService>();
|
||||||
|
builder.Services.AddScoped<EnvelopeReceiverService>();
|
||||||
|
builder.Services.AddScoped<SignatureService>();
|
||||||
|
builder.Services.AddScoped<SignatureCacheService>();
|
||||||
|
builder.Services.AddSingleton<AppVersionService>();
|
||||||
|
|
||||||
// YARP Reverse Proxy
|
// YARP Reverse Proxy
|
||||||
builder.Services.AddReverseProxy()
|
builder.Services.AddReverseProxy()
|
||||||
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
|
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
|
||||||
|
|||||||
Reference in New Issue
Block a user