using WorkFlow.API.Filters; using WorkFlow.API.Models; namespace WorkFlow.API.Extensions { public static class DIExtensions { public static IServiceCollection AddAPIKeyAuth(this IServiceCollection services, Func isValidKey, string headerName = "X-API-Key") => services.AddSingleton(provider => new(isValidKey: isValidKey, headerName: headerName)); public static IServiceCollection AddAPIKeyAuth(this IServiceCollection services, APIKeyAuthOptions options) => services.AddAPIKeyAuth(isValidKey: key => options.Key is null || options.Key == key, headerName: options.HeaderName); } }