public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { SwashbuckleStartup.Init(app, Configuration); AuthStartup.Init(app); CorsStartup.Init(app, Configuration); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHsts(); app.UseSerilogRequestLogging(); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public void ConfigureServices(IServiceCollection services) { SwashbuckleStartup.Init(services, Configuration); DiStartup.Init(services, Configuration); AuthStartup.Init(services, Configuration); CorsStartup.Init(services, Configuration); services .AddControllers() .AddJsonOptions(jsonOptions => { var jsonStringEnumConverter = new JsonStringEnumConverter(); jsonOptions.JsonSerializerOptions.Converters.Add(jsonStringEnumConverter); }); }
public void Configuration(IAppBuilder app) { //Database.SetInitializer(new MigrateDatabaseToLatestVersion<ApplicationDbContext, Migrations.Configuration>()); //Database.SetInitializer(new MigrateDatabaseToLatestVersion<BusinessDbContext, Model.Migrations.Configuration>()); app.MapSignalR(); AuthStartup.Register(app); HangfireConfig.RegisterHangfire(app); LoggerConfig.Register(); //BusinessModelSeedDataManager.RunSeed(); SecurityModelSeedDataManager.RunSeed(); BusinessModelSeedDataManager.FillTenantSubscription(); BusinessModelSeedDataManager.CreateFiscalYear(BusinessDbContext.Create()); }
/// <summary> /// Middleware Configuration. /// The HTTP request pipeline that handles each request received. /// </summary> /// <param name="app"></param> /// <param name="env"></param> /// <param name="loggerFactory"></param> public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); ILogger logger = loggerFactory.CreateLogger <Startup>(); AuthStartup.Configure(app); app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseSwagger(); app.UseSwaggerUi("api/ui", "/swagger/v" + MajorVersion + "/swagger.json"); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseWS((builder) => { IWSConnectionHandler mainHandler = serviceProvider.GetService <WSConnectionHandler>(); mainHandler.AddController(serviceProvider.GetService <SocketController>()); builder.AddConnectionHandler("/ws", mainHandler); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseRouting(); AuthStartup.UseAuthentication(app); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); SwaggerStartup.UseSwagger(app); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; }); using var scope = app.ApplicationServices.CreateScope(); using var dbContext = scope.ServiceProvider.GetRequiredService <ArchitectDbContext>(); dbContext.Database.EnsureCreated(); }
/// <summary> /// Services configuration handler. /// /// Use this function to create singleton that /// can be injected to the app's classes. /// </summary> /// <param name="services"></param> public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddApplicationInsightsTelemetry(Configuration); services.AddOptions(); AuthStartup.ConfigureServices(services, Configuration.GetSection("Jwt")); services.AddApiVersioning(o => { o.DefaultApiVersion = new ApiVersion(MajorVersion, 0); o.AssumeDefaultVersionWhenUnspecified = true; }); services.AddSwaggerGen(c => { c.SingleApiVersion(new Info { Title = "ChatApp API - v" + MajorVersion, Version = "v" + MajorVersion, Description = "Onion Architecture based chat API with JWT auth, made with dotnet core.", TermsOfService = "Knock yourself out", Contact = new Contact { Name = "Angel Kyriako", Email = "*****@*****.**" }, License = new License { Name = "Apache 2.0", Url = "http://www.apache.org/licenses/LICENSE-2.0.html" } }); }); services.AddMvc(config => { config.Filters.Add(new AuthorizeFilter(AuthStartup.DefaultPolicy)); }); services.AddWS(); ConfigureInjectedServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddLogging(builder => builder.AddFile("Logs/Architect-{Date}.txt")); services.AddControllersWithViews(options => options.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes = true); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; }); AuthStartup.AddAuthentication(services); SwaggerStartup.AddSwaggerService(services); services.AddDbContext <ArchitectDbContext>(optionsBuilder => { optionsBuilder.UseSqlServer(Configuration.GetConnectionString("Architect")); }); services.AddTransient <IRepositoryUnit, RepositoryUnit>(); services.AddTransient <IServiceUnit, ServiceUnit>(); }
public void Configuration(IAppBuilder appBuilder) { AuthStartup.ConfigureAuth(appBuilder); WebApiStartup.StartWebApi(appBuilder); }