Add middleware: Exception handling and rewrite/redirect

This commit is contained in:
flightlevel
2018-05-05 17:08:46 +10:00
parent f162902b36
commit 5eed9d7038
4 changed files with 139 additions and 0 deletions

View File

@@ -3,9 +3,11 @@ using Autofac.Extensions.DependencyInjection;
using Jackett.Common.Models.Config;
using Jackett.Common.Plumbing;
using Jackett.Common.Services.Interfaces;
using Jackett.Server.Middleware;
using Jackett.Server.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
@@ -59,6 +61,14 @@ namespace Jackett.Server
app.UseDeveloperExceptionPage();
app.UseCustomExceptionHandler();
var rewriteOptions = new RewriteOptions()
.Add(RewriteRules.RewriteBasePath)
.Add(RedirectRules.RedirectToDashboard);
app.UseRewriter(rewriteOptions);
app.UseFileServer(new FileServerOptions
{
FileProvider = new PhysicalFileProvider(Initialisation.ConfigService.GetContentFolder()),