Skip to content

Commit

Permalink
Update FeatureEndpointExtensions.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Dec 11, 2024
1 parent a7537f7 commit b32cac3
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<IFeatureEndpoint>();
var features = string.IsNullOrEmpty(serviceKey)
? builder.ServiceProvider.GetServices<IFeatureEndpoint>()
: builder.ServiceProvider.GetKeyedServices<IFeatureEndpoint>(serviceKey);

foreach (var feature in features)
feature.AddRoutes(featureGroup);

Expand Down

0 comments on commit b32cac3

Please sign in to comment.