From 2325522b98ed44569cb14c230b98ea24a0d17370 Mon Sep 17 00:00:00 2001 From: Julien Leicher Date: Thu, 10 Dec 2020 09:43:44 +0100 Subject: [PATCH] lowercase routes (#21) --- Apps/Website/Controllers/LinksController.cs | 2 +- Apps/Website/Startup.cs | 8 ++++++++ README.md | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Apps/Website/Controllers/LinksController.cs b/Apps/Website/Controllers/LinksController.cs index c99c365..0b1a48a 100644 --- a/Apps/Website/Controllers/LinksController.cs +++ b/Apps/Website/Controllers/LinksController.cs @@ -21,7 +21,7 @@ namespace Website.Controllers return View(await _bus.Send(new ListLinksQuery())); } - [HttpGet("{controller}/{id}")] + [HttpGet("{controller}/{id:guid}")] public async Task Show(Guid id) { return View(await _bus.Send(new GetLinkQuery(id))); diff --git a/Apps/Website/Startup.cs b/Apps/Website/Startup.cs index 9c75581..8b38b93 100644 --- a/Apps/Website/Startup.cs +++ b/Apps/Website/Startup.cs @@ -4,6 +4,7 @@ using HN.Infrastructure; using MediatR; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Routing; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -27,6 +28,13 @@ namespace Website services.AddScoped(); services.AddScoped(); services.AddMediatR(typeof(HN.Application.AddLinkCommand)); + + services.Configure(options => + { + options.LowercaseUrls = true; + options.LowercaseQueryStrings = true; + }); + services.AddControllersWithViews(); } diff --git a/README.md b/README.md index 8bd7cee..3cbcf30 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ Mise en place de la couche applicative avec `MediatR` et implémentation du prem ## Le site internet en MVC +### Options pattern + +Permet d'avoir des objets de configuration facilement sortable depuis l'appsettings. Utilisation de https://docs.microsoft.com/fr-fr/aspnet/core/fundamentals/configuration/options?view=aspnetcore-5.0. + ### Ajout des messages "flashs" Permet de notifier l'utilisateur d'une action. Utilisation des `TempData` (données supprimées à la prochaine requête ou après la lecture).