using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using {{ namespace }}.Core;

namespace {{ namespace }}.Http;

public sealed class CorsHeaderMiddleware(RequestDelegate next, IOptions<McpifyOptions> options)
{
    public async Task InvokeAsync(HttpContext context)
    {
        await next(context);
        if (!string.IsNullOrEmpty(options.Value.CorsAllow))
        {
            context.Response.Headers["Access-Control-Allow-Origin"] = options.Value.CorsAllow;
        }
    }
}
