From b32cac3dd663fc6efcf6ead9bba1f90f7f12abbd Mon Sep 17 00:00:00 2001 From: Paul Welter Date: Wed, 11 Dec 2024 14:05:34 -0600 Subject: [PATCH] Update FeatureEndpointExtensions.cs --- .../FeatureEndpointExtensions.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/MediatR.CommandQuery.Endpoints/FeatureEndpointExtensions.cs b/src/MediatR.CommandQuery.Endpoints/FeatureEndpointExtensions.cs index ca7bca3..523fd19 100644 --- a/src/MediatR.CommandQuery.Endpoints/FeatureEndpointExtensions.cs +++ b/src/MediatR.CommandQuery.Endpoints/FeatureEndpointExtensions.cs @@ -13,11 +13,14 @@ public static IServiceCollection AddFeatureEndpoints(this IServiceCollection ser return services; } - public static IEndpointConventionBuilder MapFeatureEndpoints(this IEndpointRouteBuilder builder, string prefix = "/api") + public static IEndpointConventionBuilder MapFeatureEndpoints(this IEndpointRouteBuilder builder, string prefix = "/api", string? serviceKey = null) { var featureGroup = builder.MapGroup(prefix); - var features = builder.ServiceProvider.GetServices(); + var features = string.IsNullOrEmpty(serviceKey) + ? builder.ServiceProvider.GetServices() + : builder.ServiceProvider.GetKeyedServices(serviceKey); + foreach (var feature in features) feature.AddRoutes(featureGroup);