diff --git a/src/Simplify.Web/Controllers/Execution/ControllerExecutorResolver.cs b/src/Simplify.Web/Controllers/Execution/ControllerExecutorResolver.cs index a955785e..b6e8f140 100644 --- a/src/Simplify.Web/Controllers/Execution/ControllerExecutorResolver.cs +++ b/src/Simplify.Web/Controllers/Execution/ControllerExecutorResolver.cs @@ -5,7 +5,7 @@ namespace Simplify.Web.Controllers.Execution; -public class ControllerExecutorResolver(IEnumerable executors) : IControllerExecutorResolver +public class ControllerExecutorResolver(IReadOnlyList executors) : IControllerExecutorResolver { public IControllerExecutor Resolve(IControllerMetadata controller) => executors.FirstOrDefault(x => x.CanHandle(controller)) diff --git a/src/Simplify.Web/Controllers/RouteMatching/Matcher/IRouteMatchResult.cs b/src/Simplify.Web/Controllers/RouteMatching/IRouteMatchResult.cs similarity index 87% rename from src/Simplify.Web/Controllers/RouteMatching/Matcher/IRouteMatchResult.cs rename to src/Simplify.Web/Controllers/RouteMatching/IRouteMatchResult.cs index eee6f092..e6ebad35 100644 --- a/src/Simplify.Web/Controllers/RouteMatching/Matcher/IRouteMatchResult.cs +++ b/src/Simplify.Web/Controllers/RouteMatching/IRouteMatchResult.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Simplify.Web.Controllers.RouteMatching.Matcher; +namespace Simplify.Web.Controllers.RouteMatching; /// /// Represent an HTTP route matching result. diff --git a/src/Simplify.Web/Controllers/RouteMatching/Matcher/IRouteMatcher.cs b/src/Simplify.Web/Controllers/RouteMatching/IRouteMatcher.cs similarity index 72% rename from src/Simplify.Web/Controllers/RouteMatching/Matcher/IRouteMatcher.cs rename to src/Simplify.Web/Controllers/RouteMatching/IRouteMatcher.cs index 8d8a3a91..50a51e25 100644 --- a/src/Simplify.Web/Controllers/RouteMatching/Matcher/IRouteMatcher.cs +++ b/src/Simplify.Web/Controllers/RouteMatching/IRouteMatcher.cs @@ -1,10 +1,14 @@ -namespace Simplify.Web.Controllers.RouteMatching.Matcher; +using Simplify.Web.Meta.Controllers; + +namespace Simplify.Web.Controllers.RouteMatching; /// /// Represent a HTTP route parser and matcher. /// public interface IRouteMatcher { + bool CanHandle(IControllerMetadata controller); + /// /// Matches the specified route. /// diff --git a/src/Simplify.Web/Controllers/RouteMatching/IRouteMatcherResolver.cs b/src/Simplify.Web/Controllers/RouteMatching/IRouteMatcherResolver.cs index 35c7afa5..402f7410 100644 --- a/src/Simplify.Web/Controllers/RouteMatching/IRouteMatcherResolver.cs +++ b/src/Simplify.Web/Controllers/RouteMatching/IRouteMatcherResolver.cs @@ -1,4 +1,3 @@ -using Simplify.Web.Controllers.RouteMatching.Matcher; using Simplify.Web.Meta.Controllers; namespace Simplify.Web.Controllers.RouteMatching; diff --git a/src/Simplify.Web/Controllers/RouteMatching/RouteMatcherResolver.cs b/src/Simplify.Web/Controllers/RouteMatching/RouteMatcherResolver.cs new file mode 100644 index 00000000..0dddc691 --- /dev/null +++ b/src/Simplify.Web/Controllers/RouteMatching/RouteMatcherResolver.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Simplify.Web.Meta.Controllers; + +namespace Simplify.Web.Controllers.RouteMatching; + +public class RouteMatcherResolver(IReadOnlyList matchers) : IRouteMatcherResolver +{ + public IRouteMatcher Resolve(IControllerMetadata controller) => + matchers.FirstOrDefault(x => x.CanHandle(controller)) + ?? throw new InvalidOperationException("No matching route matcher found for controller type: " + controller.ControllerType); +} \ No newline at end of file diff --git a/src/Simplify.Web/Controllers/RouteMatching/Matcher/IControllerPath.cs b/src/Simplify.Web/Controllers/V1/Matcher/IControllerPath.cs similarity index 100% rename from src/Simplify.Web/Controllers/RouteMatching/Matcher/IControllerPath.cs rename to src/Simplify.Web/Controllers/V1/Matcher/IControllerPath.cs diff --git a/src/Simplify.Web/Controllers/RouteMatching/Matcher/IControllerPathParser.cs b/src/Simplify.Web/Controllers/V1/Matcher/IControllerPathParser.cs similarity index 100% rename from src/Simplify.Web/Controllers/RouteMatching/Matcher/IControllerPathParser.cs rename to src/Simplify.Web/Controllers/V1/Matcher/IControllerPathParser.cs diff --git a/src/Simplify.Web/Controllers/RouteMatching/Matcher/PathItem.cs b/src/Simplify.Web/Controllers/V1/Matcher/PathItem.cs similarity index 100% rename from src/Simplify.Web/Controllers/RouteMatching/Matcher/PathItem.cs rename to src/Simplify.Web/Controllers/V1/Matcher/PathItem.cs