using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEA_Core.Middlewares
{
public class HttpRequestMiddleware
{
private readonly RequestDelegate _next;
public HttpRequestMiddleware(RequestDelegate next)
{
_next = next;
}
///
/// 中间件方法,用于处理HTTP请求上下文。
/// 向响应头添加"Access-Control-Expose-Headers"字段,允许客户端访问自定义头"WIDESEA_exp"。
///
/// HTTP请求上下文对象
/// 异步任务
public async Task InvokeAsync(HttpContext context)
{
context.Response.Headers.Add("Access-Control-Expose-Headers", "WIDESEA_exp");
await _next(context);
}
}
}