Skip to content

Class EndpointMappingExtensions ​

Namespace: Momentum.ServiceDefaults.Api
Assembly: Momentum.ServiceDefaults.Api.dll

csharp
[ExcludeFromCodeCoverage]
public static class EndpointMappingExtensions

Inheritance ​

object ← EndpointMappingExtensions

Inherited Members ​

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Methods ​

MapEndpoints(IEndpointRouteBuilder, Assembly?, Func<Type, bool>?) ​

Discovers classes implementing in the specified assembly and maps their endpoints under a shared parent group.

csharp
public static RouteGroupBuilder MapEndpoints(this IEndpointRouteBuilder routeBuilder, Assembly? assembly = null, Func<Type, bool>? predicate = null)

Parameters ​

routeBuilder IEndpointRouteBuilder

The endpoint route builder to register endpoints with.

assembly Assembly?

The assembly to scan for endpoint definitions. Defaults to the entry assembly.

predicate Func<Type, bool>?

Optional filter selecting which endpoint definition types this call maps. When null, all discovered definitions are mapped. Call this method multiple times with complementary predicates to give different endpoint sets different conventions — e.g. one call with .RequireAuthorization() and another without. Predicates should partition the types so none is mapped twice (which would produce duplicate routes).

Returns ​

RouteGroupBuilder

The parent the matched feature groups are nested under, so conventions applied to it fan out to every endpoint mapped by this call — e.g. app.MapEndpoints(asm, IsAdminEndpoint).RequireAuthorization().

Exceptions ​

InvalidOperationException

Thrown when no assembly is provided and the entry assembly cannot be determined.