Revert "refactor(middleware): Entferne WebApiMiddleware"
This reverts commit bb61c6dca0534ccb3f074bd414aecbc5872dd1c0.
This commit is contained in:
parent
bb61c6dca0
commit
381f428f77
25
HRD.WebApi/Middleware/WebApiMiddleware.cs
Normal file
25
HRD.WebApi/Middleware/WebApiMiddleware.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HRD.WebApi.DAL.Middleware
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current API resource name from HTTP context
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="httpContext">The HTTP context</param>
|
||||||
|
/// <returns>The current resource name if available, otherwise an empty string</returns>
|
||||||
|
|
||||||
|
public class WebApiMiddleware
|
||||||
|
{
|
||||||
|
private readonly RequestDelegate _next;
|
||||||
|
private readonly ILogger<WebApiMiddleware> _logger;
|
||||||
|
|
||||||
|
public WebApiMiddleware(RequestDelegate next, ILogger<WebApiMiddleware> logger)
|
||||||
|
{
|
||||||
|
_next = next;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,6 +6,11 @@ namespace HRD.WebApi.DAL.Middleware
|
|||||||
{
|
{
|
||||||
public static class WebApiMiddlewareExtensions
|
public static class WebApiMiddlewareExtensions
|
||||||
{
|
{
|
||||||
|
public static IApplicationBuilder UseDALMiddleware(this IApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
return builder.UseMiddleware<WebApiMiddleware>();
|
||||||
|
}
|
||||||
|
|
||||||
public static void ConfigureDAL(this IServiceCollection services, WebApiMiddlewareOptions options)
|
public static void ConfigureDAL(this IServiceCollection services, WebApiMiddlewareOptions options)
|
||||||
{
|
{
|
||||||
if (options == null)
|
if (options == null)
|
||||||
|
|||||||
@ -144,6 +144,7 @@ try
|
|||||||
app.UseDefaultFiles();
|
app.UseDefaultFiles();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseOpenApi();
|
app.UseOpenApi();
|
||||||
|
app.UseDALMiddleware();
|
||||||
app.UseJwtMiddleware();
|
app.UseJwtMiddleware();
|
||||||
app.UseSwaggerUi(cfg => cfg.DocExpansion = "none");
|
app.UseSwaggerUi(cfg => cfg.DocExpansion = "none");
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user