lowercase routes #21

Merged
jleicher merged 1 commits from configure-routes into master 2020-12-10 09:43:44 +01:00
3 changed files with 13 additions and 1 deletions
Showing only changes of commit ce1f15721b - Show all commits

View File

@ -21,7 +21,7 @@ namespace Website.Controllers
return View(await _bus.Send(new ListLinksQuery())); return View(await _bus.Send(new ListLinksQuery()));
} }
[HttpGet("{controller}/{id}")] [HttpGet("{controller}/{id:guid}")]
public async Task<IActionResult> Show(Guid id) public async Task<IActionResult> Show(Guid id)
{ {
return View(await _bus.Send(new GetLinkQuery(id))); return View(await _bus.Send(new GetLinkQuery(id)));

View File

@ -4,6 +4,7 @@ using HN.Infrastructure;
using MediatR; using MediatR;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Routing;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -27,6 +28,13 @@ namespace Website
services.AddScoped<IDbContext, HNDbContext>(); services.AddScoped<IDbContext, HNDbContext>();
services.AddScoped<ILinkRepository, LinkRepository>(); services.AddScoped<ILinkRepository, LinkRepository>();
services.AddMediatR(typeof(HN.Application.AddLinkCommand)); services.AddMediatR(typeof(HN.Application.AddLinkCommand));
services.Configure<RouteOptions>(options =>
{
options.LowercaseUrls = true;
options.LowercaseQueryStrings = true;
});
services.AddControllersWithViews(); services.AddControllersWithViews();
} }

View File

@ -19,6 +19,10 @@ Mise en place de la couche applicative avec `MediatR` et implémentation du prem
## Le site internet en MVC ## 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" ### 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). Permet de notifier l'utilisateur d'une action. Utilisation des `TempData` (données supprimées à la prochaine requête ou après la lecture).