diff --git a/SimpleHttpServer/HttpServer.cs b/SimpleHttpServer/HttpServer.cs index 3bffdc5..b738e30 100644 --- a/SimpleHttpServer/HttpServer.cs +++ b/SimpleHttpServer/HttpServer.cs @@ -132,11 +132,12 @@ public sealed class HttpServer { } // stores the check attributes that are defined on the method and on the containing class - var requiredChecks = mi.GetCustomAttributes(true).Concat(mi.DeclaringType?.GetCustomAttributes(true) ?? Enumerable.Empty()) - .Where(a => a.GetType().IsAssignableTo(typeof(InternalEndpointCheckAttribute))).Cast().ToArray(); + InternalEndpointCheckAttribute[] requiredChecks = mi.GetCustomAttributes(true) + .Concat(mi.DeclaringType?.GetCustomAttributes(true) ?? Enumerable.Empty()) + .Where(a => a.GetType().IsAssignableTo(typeof(InternalEndpointCheckAttribute))) + .Cast().ToArray(); - foreach (var requiredCheck in requiredChecks) - requiredCheck.SetInstance(classInstance); + InternalEndpointCheckAttribute.Initialize(classInstance, requiredChecks); foreach (var location in attrib.Locations) { var normLocation = NormalizeUrlPath(location);