1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    public class EndPointUrlPolicy : IUrlPolicy
    {
        public bool Matches(ActionCall call)
        {
            return call.HandlerType.Name.EndsWith("Endpoint");
        }

        public IRouteDefinition Build(ActionCall call)
        {
            var routeDefinition = call.ToRouteDefinition();
            routeDefinition.Append(call.HandlerType.Name.Replace("Endpoint", string.Empty).ToLower());
            if (call.HasInput && typeof(IHaveAnId).IsAssignableFrom(call.InputType()))
            {
                var idInput = new RouteInput(ReflectionHelper.GetAccessor<IHaveAnId>(x => x.Id));
                routeDefinition.AddRouteInput(idInput, true);
            }
            return routeDefinition;
        }
    }