71 lines
1.6 KiB
C#
71 lines
1.6 KiB
C#
|
|
using UIStandardWebApi.SqlSuggar;
|
|
using UIStandardWebApi.Utility.RegisterExt;
|
|
using UIStandardWebApi.WebCore.AutoMapExtend;
|
|
using UIStandardWebApi.WebCore.CorsExtend;
|
|
using UIStandardWebApi.WebCore.SwaggerExtend;
|
|
|
|
namespace UIStandardWebApi
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
//服务注册
|
|
builder.RegistService();
|
|
|
|
//配置解决中文乱码等问题
|
|
builder.RegistControllers();
|
|
|
|
//Swagger
|
|
builder.Services.AddSwaggerExt("软件标准化Api文档", "软件标准化Api文档");
|
|
|
|
//Automapper注册
|
|
builder.Services.AddAutoMapper(typeof(AutoMapperConfigs));
|
|
|
|
|
|
builder.Services.AddMemoryCache();
|
|
|
|
//跨域
|
|
builder.Services.AddCorsExt();
|
|
|
|
builder.InitSqlSugar(); //注册SqlSugar
|
|
|
|
if (builder.Configuration["IsInitDatabase"] == "1")
|
|
{
|
|
builder.InitDatabase();
|
|
}
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
//使用Swagger
|
|
app.UseSwaggerExt("软件标准化Api文档");
|
|
|
|
//使用跨域策略
|
|
app.UseCorsExt();
|
|
|
|
//映射默认的 MVC 路由
|
|
app.MapControllers();
|
|
|
|
//让应用程序把 HTTP 请求重定向到 HTTPS 请求,以此增强应用程序的安全性
|
|
app.UseHttpsRedirection();
|
|
|
|
// 使用身份验证中间件
|
|
app.UseAuthentication();
|
|
// 使用授权中间件
|
|
app.UseAuthorization();
|
|
|
|
|
|
app.Run();
|
|
}
|
|
}
|
|
}
|