add(filter): 新增全局错误拦截器

This commit is contained in:
2025-12-15 17:30:58 +08:00
parent 82652efed7
commit 3725af7952
3 changed files with 400 additions and 728 deletions
+5 -1
View File
@@ -1,5 +1,6 @@
using IM_API.Configs;
using IM_API.Filters;
using IM_API.Hubs;
using IM_API.Models;
using Microsoft.AspNetCore.Authentication.JwtBearer;
@@ -97,7 +98,10 @@ namespace IM_API
}
};
});
builder.Services.AddControllers();
builder.Services.AddControllers(options =>
{
options.Filters.Add<GlobalExceptionFilter>();
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();