From f130a0da7e57c9aef687597b255119335971e1ef Mon Sep 17 00:00:00 2001 From: Roar Andersen Date: Mon, 13 Jan 2025 13:46:44 +0100 Subject: [PATCH] Added endpoint grouping for minimal apis --- WrapThat.Version/WebApplicationExtensions.cs | 21 +++++++------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/WrapThat.Version/WebApplicationExtensions.cs b/WrapThat.Version/WebApplicationExtensions.cs index 1a6858a..1ec50c8 100644 --- a/WrapThat.Version/WebApplicationExtensions.cs +++ b/WrapThat.Version/WebApplicationExtensions.cs @@ -9,20 +9,13 @@ public static class WebApplicationExtensions { public static WebApplication MapVersionApiEndpoints(this WebApplication app) { - var controller = new InfoController(); - - app.MapGet("/api/info", [AllowAnonymous] () => HandleRequest(c=>c.Info())); - - app.MapGet("/api/info/version", [AllowAnonymous] () => HandleRequest(c => c.Version())); - - app.MapGet("/api/info/productversion", [AllowAnonymous] () => HandleRequest(c => c.ProductVersion())); - - app.MapGet("/api/info/shields/version", [AllowAnonymous] () => HandleRequest(c => c.InfoShields())); - - app.MapGet("/api/info/shields/productversion", [AllowAnonymous] () => HandleRequest(c => c.ProductVersionShields())); - - app.MapGet("/api/info/status", [AllowAnonymous] () => HandleRequest(c => c.Status())); - + var infoGroup = app.MapGroup("/api/info").WithTags("Version"); + infoGroup.MapGet("/", [AllowAnonymous] () => HandleRequest(c=>c.Info())); + infoGroup.MapGet("/version", [AllowAnonymous] () => HandleRequest(c => c.Version())); + infoGroup.MapGet("/productversion", [AllowAnonymous] () => HandleRequest(c => c.ProductVersion())); + infoGroup.MapGet("/shields/version", [AllowAnonymous] () => HandleRequest(c => c.InfoShields())); + infoGroup.MapGet("/shields/productversion", [AllowAnonymous] () => HandleRequest(c => c.ProductVersionShields())); + infoGroup.MapGet("/status", [AllowAnonymous] () => HandleRequest(c => c.Status())); return app; }