rtmpdash/Startup.cs

65 lines
1.8 KiB
C#
Raw Normal View History

2021-01-24 04:04:16 +01:00
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
2022-02-09 22:32:17 +01:00
namespace RTMPDash;
2021-01-24 04:04:16 +01:00
2022-02-09 22:32:17 +01:00
public class Startup {
public Startup(IConfiguration configuration) => Configuration = configuration;
2021-01-24 04:04:16 +01:00
2022-02-09 22:32:17 +01:00
public IConfiguration Configuration { get; }
2021-01-24 04:04:16 +01:00
2022-02-09 22:32:17 +01:00
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) {
services.AddRazorPages();
services.AddSession(options => {
options.IdleTimeout = TimeSpan.MaxValue;
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
#if (DEBUG)
services.AddControllers().AddRazorRuntimeCompilation();
services.AddStackExchangeRedisCache(options => {
options.Configuration = "localhost";
options.InstanceName = "RTMPdash_development";
});
#else
2021-01-24 04:04:16 +01:00
services.AddControllers();
2021-01-28 00:15:16 +01:00
services.AddStackExchangeRedisCache(options =>
{
options.Configuration = "localhost";
options.InstanceName = "RTMPdash_production";
});
2022-02-09 22:32:17 +01:00
#endif
}
2021-01-24 04:04:16 +01:00
2022-02-09 22:32:17 +01:00
// 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();
}
2021-01-24 04:04:16 +01:00
2022-02-09 22:32:17 +01:00
app.UseStaticFiles();
2021-01-24 04:04:16 +01:00
2022-02-09 22:32:17 +01:00
app.UseSession();
2021-01-24 04:04:16 +01:00
2022-02-09 22:32:17 +01:00
app.UseRouting();
2021-01-24 04:04:16 +01:00
2022-02-09 22:32:17 +01:00
app.UseAuthentication();
app.UseAuthorization();
2021-01-24 04:04:16 +01:00
2022-02-09 22:32:17 +01:00
app.UseEndpoints(endpoints => {
endpoints.MapRazorPages();
endpoints.MapControllers();
});
2021-01-24 04:04:16 +01:00
}
}