public void Apply(ActionCall call, IRouteDefinition routeDefinition)
 {
     var httpMethods = _httpMethodFilters.Where(x => x.Filter(call)).Select(x => x.Method).ToArray();
     if (httpMethods.Length > 0)
     {
         routeDefinition.AddRouteConstraint(HTTP_METHOD_CONSTRAINT, new HttpMethodConstraint(httpMethods));
     }
 }
Esempio n. 2
0
        public static void ConstrainToHttpMethods(this IRouteDefinition routeDef, params string[] methods)
        {
            if (methods.Length == 0)
            {
                return;
            }

            routeDef.AddRouteConstraint(RouteConstraintPolicy.HTTP_METHOD_CONSTRAINT, new HttpMethodConstraint(methods));
        }
Esempio n. 3
0
        public void Apply(ActionCall call, IRouteDefinition routeDefinition, IConfigurationObserver observer)
        {
            var matchingFilters = _httpMethodFilters.Where(x => x.Filter(call));

            var httpMethods = matchingFilters.Select(x => x.Method).ToArray();

            if (httpMethods.Length > 0)
            {
                routeDefinition.AddRouteConstraint(HTTP_METHOD_CONSTRAINT, new HttpMethodConstraint(httpMethods));
                matchingFilters.Each(filter => observer.RecordCallStatus(call,
                                                                         "Adding route constraint {0} based on filter [{1}]".ToFormat(filter.Method, filter.Description)));
            }
        }
        public void Apply(ActionCall call, IRouteDefinition routeDefinition, IConfigurationObserver observer)
        {
            var matchingFilters = _httpMethodFilters.Where(x => x.Filter(call));

            var httpMethods = matchingFilters.Select(x => x.Method).ToArray();
            if (httpMethods.Length > 0)
            {
                routeDefinition.AddRouteConstraint(HTTP_METHOD_CONSTRAINT, new HttpMethodConstraint(httpMethods));
                matchingFilters.Each(filter => observer.RecordCallStatus(call,
                    "Adding route constraint {0} based on filter [{1}]".ToFormat(filter.Method, filter.Description)));

            }
        }