using Microsoft.AspNetCore.Builder;
namespace Prefab.Endpoints;
///
/// Provides extension methods for configuring endpoint names with module-based naming conventions in ASP.NET Core
/// routing.
///
/// These methods help standardize endpoint naming by prefixing endpoint names with a module name
/// inferred from a specified type. This can improve discoverability and organization of endpoints, especially in
/// modular applications. The extensions are intended for use with ASP.NET Core's routing infrastructure and are
/// typically called when configuring endpoints in minimal APIs or similar scenarios.
public static class Extensions
{
///
/// Applies an endpoint name that combines the module name inferred from with the type name.
///
/// A type that belongs to the module the endpoint lives in, typically the endpoint class itself.
public static RouteHandlerBuilder WithModuleName(this RouteHandlerBuilder builder)
=> builder.WithModuleName(typeof(T).Name);
///
/// Applies an endpoint name that combines the module name inferred from with the provided endpoint name.
///
/// A type that belongs to the module the endpoint lives in, typically the endpoint class itself.
/// The base endpoint name that will be prefixed with the module name.
public static RouteHandlerBuilder WithModuleName(this RouteHandlerBuilder builder, string endpointName)
=> builder.WithName(EndpointName.For(endpointName));
}