private static IRouteDefinition buildStandardRoute(ActionCall call) { var route = call.ToRouteDefinition(); MethodToUrlBuilder.Alter(route, call); return(route); }
public void allow_get_as_a_prefix() { MethodToUrlBuilder.Alter(theRoute, "GetPath", theProperties, x => Debug.WriteLine(x)); theRoute.Pattern.ShouldEqual("getpath"); theRoute.AllowedHttpMethods.Any().ShouldBeFalse(); }
public void use_separator_and_substitution_for_matching_property() { theProperties.Add("Input1"); MethodToUrlBuilder.Alter(theRoute, "path_Input1_folder", theProperties, x => Debug.WriteLine(x)); theRoute.Pattern.ShouldEqual("path/{Input1}/folder"); }
public void create_http_constraint_for_put() { MethodToUrlBuilder.Alter(theRoute, "Put_path", theProperties, x => Debug.WriteLine(x)); theRoute.Pattern.ShouldEqual("path"); theRoute.AllowedHttpMethods.ShouldHaveTheSameElementsAs("PUT"); }
public void create_http_constraint_for_post() { MethodToUrlBuilder.Alter(theRoute, "post_path", theProperties); theRoute.Pattern.ShouldEqual("path"); theRoute.AllowedHttpMethods.ShouldHaveTheSameElementsAs("POST"); }
public void multiple_substitutions() { theProperties.Add("Start"); theProperties.Add("End"); MethodToUrlBuilder.Alter(theRoute, "cases_from_Start_to_End", theProperties, x => Debug.WriteLine(x)); theRoute.Pattern.ShouldEqual("cases/from/{Start}/to/{End}"); }
public void multiple_substitutions_and_folders_and_constraint() { theProperties.Add("Start"); theProperties.Add("End"); MethodToUrlBuilder.Alter(theRoute, "get_cases_from_Start_to_End", theProperties, x => Debug.WriteLine(x)); theRoute.Pattern.ShouldEqual("cases/from/{Start}/to/{End}"); theRoute.AllowedHttpMethods.ShouldContain("GET"); }
public void http_verb_only_should_not_modify_route() { const string originalRoute = "base/route"; theRoute.Append(originalRoute); MethodToUrlBuilder.Alter(theRoute, "get", theProperties, x => Debug.WriteLine(x)); theRoute.Pattern.ShouldEqual(originalRoute); theRoute.AllowedHttpMethods.ShouldContain("GET"); }
public virtual IRouteDefinition Build(ActionCall call) { var routeDefinition = call.ToRouteDefinition(); var strippedNamespace = stripNamespace(call); visit(routeDefinition); if (strippedNamespace != call.HandlerType.Namespace) { if (!strippedNamespace.Contains(".")) { routeDefinition.Append(breakUpCamelCaseWithHypen(strippedNamespace)); } else { var patternParts = strippedNamespace.Split(new[] { "." }, StringSplitOptions.None); foreach (var patternPart in patternParts) { routeDefinition.Append(breakUpCamelCaseWithHypen(patternPart.Trim())); } } } var handlerName = call.HandlerType.Name; var match = HandlerExpression.Match(handlerName); if (match.Success && MethodToUrlBuilder.Matches(handlerName)) { // We're forcing handlers to end with "_handler" in this case handlerName = handlerName.Substring(0, match.Index); var properties = call.HasInput ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys : new string[0]; MethodToUrlBuilder.Alter(routeDefinition, handlerName, properties); } else { // Otherwise we're expecting something like "GetHandler" var httpMethod = call.HandlerType.Name.Replace(HANDLER, string.Empty); routeDefinition.ConstrainToHttpMethods(httpMethod.ToUpper()); } if (call.HasInput) { routeDefinition.ApplyInputType(call.InputType()); } return(routeDefinition); }
public static IRouteDefinition BuildRoute(ActionCall call) { var prefix = call.HandlerType.Name.Replace("FubuDiagnostics", "").ToLower(); if (call.Method.Name == "Index") { return(new RouteDefinition("{0}/{1}".ToFormat(DiagnosticsUrl, prefix).TrimEnd('/'))); } var route = call.ToRouteDefinition(); MethodToUrlBuilder.Alter(route, call); route.Prepend(prefix); route.Prepend(DiagnosticsUrl); return(route); }
public void use_separators_for_underscores_if_not_a_route_input() { MethodToUrlBuilder.Alter(theRoute, "path_folder1_folder2", theProperties, x => Debug.WriteLine(x)); theRoute.Pattern.ShouldEqual("path/folder1/folder2"); }
public void three_underscores_in_a_row_are_a_dash() { MethodToUrlBuilder.Alter(theRoute, "path_folder1___folder2", theProperties); theRoute.Pattern.ShouldEqual("path/folder1-folder2"); }
public void two_underscores_in_a_row_are_considered_to_be_an_underscore() { MethodToUrlBuilder.Alter(theRoute, "path_folder1__folder2", theProperties); theRoute.Pattern.ShouldEqual("path/folder1/_folder2"); }
public void use_separators_for_underscores_if_not_a_route_input() { MethodToUrlBuilder.Alter(theRoute, "path_folder1_folder2", theProperties); theRoute.Pattern.ShouldBe("path/folder1/folder2"); }