Files
Yi.Framework/Yi.Furion.Net6/Yi.Furion.Web.Core/Startup.cs
2023-04-16 14:30:56 +08:00

54 lines
1.3 KiB
C#

using Furion;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Yi.Framework.Infrastructure.Data.Json;
using Yi.Furion.Web.Core.Handlers;
namespace Yi.Furion.Web.Core;
public class Startup : AppStartup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddConsoleFormatter();
services.AddJwt<JwtHandler>();
services.AddCorsAccessor();
services.AddControllers().AddInjectWithUnifyResult().AddJsonOptions(x => {
//x.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
x.JsonSerializerOptions.Converters.Add(new LongToStringConverter());
});
services.AddEventBus();
services.AddHttpContextAccessor();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseCorsAccessor();
app.UseAuthentication();
app.UseAuthorization();
app.UseInject(string.Empty);
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}