z8018
2026-02-11 b8fb68b44c29e4667f6ea5746119413809a60a9e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
using KH.WMS.Core.Monitoring.MiniProfiler;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
 
namespace KH.WMS.Core.Setup;
 
/// <summary>
/// 中间件配置 - 统一入口
/// </summary>
public static class MiddlewareSetup
{
    /// <summary>
    /// 使用所有自定义中间件(按推荐顺序)
    /// </summary>
    /// <summary>
    /// 使用所有自定义中间件(按推荐顺序)
    /// </summary>
    public static IApplicationBuilder UseCustomMiddleware(this IApplicationBuilder app, IWebHostEnvironment env)
    {
        // HTTPS 重定向(生产环境)
        if (!env.IsDevelopment())
        {
            app.UseHttpsRedirection();
        }
 
        // 路由
        app.UseRouting();
 
        // 性能监控(在 UseRouting 之后)
        app.UseMiniProfilerCustom();
 
        // 认证
        app.UseAuthentication();
 
        // 授权
        app.UseAuthorization();
 
        // 端点映射
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
            endpoints.MapRazorPages();  // MiniProfiler UI 需要
        });
 
        return app;
    }
 
}