Add IRequestContext interface and RequestContext class

Introduce the IRequestContext interface with an Origin property
in the EnvelopeGenerator.Application.Common.Interfaces namespace.
Implement this interface in the new RequestContext class within
EnvelopeGenerator.Server.Services, using IHttpContextAccessor to
access the Origin header. Register IRequestContext with the DI
container in Program.cs using AddScoped. Update using directives
to include necessary namespaces and reorganize for clarity.
This commit is contained in:
2026-10-29 15:51:58 +01:00
parent 42585e1f2c
commit abf616c115
3 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
namespace EnvelopeGenerator.Application.Common.Interfaces;
/// <summary>
///
/// </summary>
public interface IRequestContext
{
/// <summary>
///
/// </summary>
string? Origin { get; }
}

View File

@@ -8,6 +8,7 @@ using DigitalData.Core.Application;
using DigitalData.EmailProfilerDispatcher;
using DigitalData.UserManager.DependencyInjection;
using EnvelopeGenerator.Application;
using EnvelopeGenerator.Application.Common.Interfaces;
using EnvelopeGenerator.Application.Common.Interfaces.Doc;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Infrastructure;
@@ -19,6 +20,7 @@ using EnvelopeGenerator.Server.Client.Services;
using EnvelopeGenerator.Server.Components;
using EnvelopeGenerator.Server.Models;
using EnvelopeGenerator.Server.Options;
using EnvelopeGenerator.Server.Services;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Localization;
@@ -392,6 +394,8 @@ try
builder.Services.Configure<EnvelopeGenerator.Server.Client.Options.PdfViewerOptions>(
builder.Configuration.GetSection("PdfViewerOptions"));
builder.Services.AddScoped<IRequestContext, RequestContext>();
var app = builder.Build();
deferredProvider.Factory = () => app.Services;

View File

@@ -0,0 +1,18 @@
using EnvelopeGenerator.Application.Common.Interfaces;
namespace EnvelopeGenerator.Server.Services;
/// <summary>
///
/// </summary>
/// <param name="HttpContextAccessor"></param>
public sealed class RequestContext(
IHttpContextAccessor HttpContextAccessor) : IRequestContext
{
/// <summary>
///
/// </summary>
public string? Origin =>
HttpContextAccessor.HttpContext?
.Request.Headers.Origin.ToString();
}