repomgr/Startup.cs

56 lines
1.8 KiB
C#
Raw Permalink Normal View History

2019-07-05 00:36:10 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
2020-06-25 22:25:11 +02:00
using Microsoft.Extensions.Hosting;
2019-07-05 00:36:10 +02:00
namespace repomgr
{
2020-06-25 22:25:11 +02:00
public class Startup {
public Startup(IConfiguration configuration) => Configuration = configuration;
2019-07-05 00:36:10 +02:00
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
2020-06-25 22:25:11 +02:00
public void ConfigureServices(IServiceCollection services) {
services.AddRazorPages();
#if (DEBUG)
services.AddControllers().AddRazorRuntimeCompilation();
#else
services.AddControllers();
#endif
2019-07-05 00:36:10 +02:00
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
2020-06-25 22:25:11 +02:00
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
if (env.IsDevelopment()) {
2019-07-05 00:36:10 +02:00
app.UseDeveloperExceptionPage();
}
2020-06-25 22:25:11 +02:00
else {
2019-07-05 00:36:10 +02:00
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();
2020-06-25 22:25:11 +02:00
2019-07-05 00:36:10 +02:00
app.UseStaticFiles();
2020-06-25 22:25:11 +02:00
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => {
endpoints.MapRazorPages();
endpoints.MapControllers();
});
2019-07-05 00:36:10 +02:00
}
}
}