From 3fbf18ca6540e1ac1e342b05192e9dbd50212496 Mon Sep 17 00:00:00 2001 From: enisn Date: Tue, 1 Feb 2022 10:10:26 +0300 Subject: [PATCH] Remove controllers and add rewrite options --- .../Controllers/HomeController.cs | 13 ------------- .../EShopOnAbpWebPublicGatewayModule.cs | 14 ++++++-------- .../Controllers/HomeController.cs | 13 ------------- .../EShopOnAbpWebGatewayModule.cs | 14 ++++++-------- 4 files changed, 12 insertions(+), 42 deletions(-) delete mode 100644 gateways/web-public/src/EShopOnAbp.WebPublicGateway/Controllers/HomeController.cs delete mode 100644 gateways/web/src/EShopOnAbp.WebGateway/Controllers/HomeController.cs diff --git a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/Controllers/HomeController.cs b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/Controllers/HomeController.cs deleted file mode 100644 index fc0b6b82..00000000 --- a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/Controllers/HomeController.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc; - -namespace EShopOnAbp.WebPublicGateway.Controllers -{ - public class HomeController : AbpController - { - public ActionResult Index() - { - return Redirect("/swagger"); - } - } -} diff --git a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs index e9af7505..faab4ab4 100644 --- a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs +++ b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbpWebPublicGatewayModule.cs @@ -9,6 +9,7 @@ using System.Linq; using EShopOnAbp.Shared.Hosting.AspNetCore; using Volo.Abp; using Volo.Abp.Modularity; +using Microsoft.AspNetCore.Rewrite; namespace EShopOnAbp.WebPublicGateway; @@ -75,14 +76,11 @@ public class EShopOnAbpWebPublicGatewayModule : AbpModule options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); } }); - app.MapWhen( - ctx => ctx.Request.Path.ToString().TrimEnd('/').Equals(""), - app2 => - { - app2.UseRouting(); - app2.UseConfiguredEndpoints(); - } - ); + + app.UseRewriter(new RewriteOptions() + // Regex for "", "/" and "" (whitespace) + .AddRedirect("^(|\\|\\s+)$", "/swagger")); + app.UseOcelot().Wait(); } } \ No newline at end of file diff --git a/gateways/web/src/EShopOnAbp.WebGateway/Controllers/HomeController.cs b/gateways/web/src/EShopOnAbp.WebGateway/Controllers/HomeController.cs deleted file mode 100644 index 6ddeb9bc..00000000 --- a/gateways/web/src/EShopOnAbp.WebGateway/Controllers/HomeController.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc; - -namespace EShopOnAbp.WebGateway.Controllers -{ - public class HomeController : AbpController - { - public ActionResult Index() - { - return Redirect("/swagger"); - } - } -} diff --git a/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs b/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs index 87974f87..a9bf6190 100644 --- a/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs +++ b/gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbpWebGatewayModule.cs @@ -11,6 +11,7 @@ using System.Linq; using EShopOnAbp.Shared.Hosting.AspNetCore; using Volo.Abp; using Volo.Abp.Modularity; +using Microsoft.AspNetCore.Rewrite; namespace EShopOnAbp.WebGateway; @@ -98,14 +99,11 @@ public class EShopOnAbpWebGatewayModule : AbpModule options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); } }); - app.MapWhen( - ctx => ctx.Request.Path.ToString().TrimEnd('/').Equals(""), - app2 => - { - app2.UseRouting(); - app2.UseConfiguredEndpoints(); - } - ); + + app.UseRewriter(new RewriteOptions() + // Regex for "", "/" and "" (whitespace) + .AddRedirect("^(|\\|\\s+)$", "/swagger")); + app.UseOcelot().Wait(); } } \ No newline at end of file