108 lines
3.8 KiB
C#
108 lines
3.8 KiB
C#
using JiShe.ServicePro.SwaggerConfigs;
|
|
using System.Reflection;
|
|
using Volo.Abp.BlobStoring.FileSystem;
|
|
|
|
namespace JiShe.IoT
|
|
{
|
|
[DependsOn(
|
|
typeof(IoTHttpApiModule),
|
|
typeof(ServiceProSharedHostingMicroserviceModule),
|
|
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
|
typeof(IoTEntityFrameworkCoreModule),
|
|
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
|
typeof(AbpAspNetCoreSerilogModule),
|
|
typeof(AbpAccountWebModule),
|
|
typeof(IoTApplicationModule),
|
|
// typeof(AbpProCapModule),
|
|
// typeof(AbpProCapEntityFrameworkCoreModule),
|
|
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
|
|
typeof(AbpCachingStackExchangeRedisModule),
|
|
typeof(AbpBlobStoringFileSystemModule),
|
|
typeof(AbpDistributedLockingModule)
|
|
//typeof(AbpBackgroundJobsHangfireModule)
|
|
)]
|
|
public partial class IoTHttpApiHostModule : AbpModule
|
|
{
|
|
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
// 应用程序初始化的时候注册hangfire
|
|
//context.CreateRecurringJob();
|
|
base.OnPostApplicationInitialization(context);
|
|
}
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var configuration = context.Services.GetConfiguration();
|
|
ConfigureCache(context);
|
|
ConfigurationDistributedLocking(context);
|
|
ConfigureSwaggerServices(context);
|
|
ConfigureJwtAuthentication(context, configuration);
|
|
//ConfigureHangfire(context);
|
|
ConfigureMiniProfiler(context);
|
|
ConfigureIdentity(context);
|
|
//ConfigureCap(context);
|
|
ConfigureAuditLog(context);
|
|
ConfigurationSignalR(context);
|
|
ConfigurationMultiTenancy();
|
|
ConfigureBlobStorage();
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
var app = context.GetApplicationBuilder();
|
|
var configuration = context.GetConfiguration();
|
|
app.UseServiceProRequestLocalization();
|
|
app.UseCorrelationId();
|
|
app.MapAbpStaticAssets();
|
|
if (configuration.GetValue("MiniProfiler:Enabled", false))
|
|
{
|
|
app.UseMiniProfiler();
|
|
}
|
|
|
|
app.UseRouting();
|
|
app.UseCors(IoTHttpApiHostConst.DefaultCorsPolicyName);
|
|
app.UseAuthentication();
|
|
|
|
if (MultiTenancyConsts.IsEnabled)
|
|
{
|
|
app.UseMultiTenancy();
|
|
}
|
|
|
|
app.UseAuthorization();
|
|
app.UseSwagger();
|
|
app.UseAbpSwaggerUI(options =>
|
|
{
|
|
var groupNames = EnumExtensions.GetStringKeyValueList<SwaggerGroupEnum>();
|
|
|
|
groupNames.ForEach(attr => {
|
|
|
|
options.SwaggerEndpoint($"/swagger/{attr.Key}/swagger.json", attr.Value);
|
|
});
|
|
//options.SwaggerEndpoint("/swagger/AbpPro/swagger.json", "AbpPro API");
|
|
|
|
options.DocExpansion(DocExpansion.None);
|
|
options.DefaultModelsExpandDepth(-1);
|
|
});
|
|
|
|
app.UseAuditing();
|
|
app.UseAbpSerilogEnrichers();
|
|
app.UseUnitOfWork();
|
|
app.UseConfiguredEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapHealthChecks("/health");
|
|
|
|
// endpoints.MapHangfireDashboard("/hangfire", new DashboardOptions()
|
|
// {
|
|
// Authorization = new[] { new CustomHangfireAuthorizeFilter() },
|
|
// IgnoreAntiforgeryToken = true
|
|
// });
|
|
|
|
});
|
|
|
|
if (configuration.GetValue("Consul:Enabled", false))
|
|
{
|
|
app.UseConsul();
|
|
}
|
|
}
|
|
}
|
|
} |