예제 #1
0
파일: Startup.cs 프로젝트: ccwssw/Orca
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IOptions <DatabaseFields> dbSettings, ILogger <Startup> logger)
        {
            if (DatabaseConnect.HasDatabase(dbSettings.Value))
            {
                logger.LogInformation("Initializing database schema");
                DatabaseConnect.CreateDatabase(dbSettings.Value, env);
            }
            else
            {
                logger.LogWarning("Database credentials are missing. Application will run without connecting to a database. Engagement events will not be persisted");
            }

            app.UseSwagger();
            app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Orca v1"));
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            if (!env.IsDevelopment())
            {
                app.UseHsts();
                app.UseHttpsRedirection();
            }

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }