public static void RegisterWebApiRoutes(System.Web.Http.HttpRouteCollection routes) { routes.MapHttpRoute( name: "ApiAction", routeTemplate: "api/{controller}/{action}", defaults: new { action = "Get" } ); }
public static void ConfigureApiGenerator(System.Web.Http.HttpRouteCollection routes, GeneratorConfig configuration) { GeneratorConfig.CheckGeneratorConfig(configuration); routes.MapHttpRoute( name: "CodeGenerator", routeTemplate: String.IsNullOrEmpty(configuration.RouteTemplate) ? "C/G/API/{action}" : configuration.RouteTemplate, defaults: null, constraints: null, handler: new GeneratorHandler(configuration) ); }
/// <summary> /// Ignores the specified route. /// </summary> /// <param name="routes">A collection of routes for the application.</param> /// <param name="routeName">The name of the route to ignore.</param> /// <param name="routeTemplate">The route template for the route.</param> public static IHttpRoute IgnoreRoute(this HttpRouteCollection routes, string routeName, string routeTemplate) { return(IgnoreRoute(routes, routeName, routeTemplate, constraints: null)); }
/// <summary> /// Maps the specified OData route. /// </summary> /// <param name="routes">A collection of routes for the application.</param> /// <param name="routeName">The name of the route to map.</param> /// <param name="routePrefix">The prefix to add to the OData route's path template.</param> /// <param name="model">The EDM model to use for parsing OData paths.</param> /// <param name="pathHandler">The <see cref="IODataPathHandler"/> to use for parsing the OData path.</param> /// <param name="routingConventions">The OData routing conventions to use for controller and action selection.</param> public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix, IEdmModel model, IODataPathHandler pathHandler, IEnumerable <IODataRoutingConvention> routingConventions) { routes.MapODataRoute(routeName, routePrefix, model, pathHandler, routingConventions, batchHandler: null); }
/// <summary> /// Maps the specified OData route. When the <paramref name="batchHandler"/> is provided, it will create a '$batch' endpoint to handle the batch requests. /// </summary> /// <param name="routes">A collection of routes for the application.</param> /// <param name="routeName">The name of the route to map.</param> /// <param name="routePrefix">The prefix to add to the OData route's path template.</param> /// <param name="model">The EDM model to use for parsing OData paths.</param> /// <param name="batchHandler">The <see cref="ODataBatchHandler"/>.</param> public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix, IEdmModel model, ODataBatchHandler batchHandler) { routes.MapODataRoute(routeName, routePrefix, model, new DefaultODataPathHandler(), ODataRoutingConventions.CreateDefault(), batchHandler); }
/// <summary> /// Maps the specified OData route. /// </summary> /// <param name="routes">A collection of routes for the application.</param> /// <param name="routeName">The name of the route to map.</param> /// <param name="routePrefix">The prefix to add to the OData route's path template.</param> /// <param name="model">The EDM model to use for parsing OData paths.</param> public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix, IEdmModel model) { routes.MapODataRoute(routeName, routePrefix, model, batchHandler: null); }
public static IHttpRoute MapHttpBatchRoute(this HttpRouteCollection routes, string routeName, string routeTemplate, HttpBatchHandler batchHandler) { return(routes.MapHttpRoute(routeName, routeTemplate, defaults: null, constraints: null, handler: batchHandler)); }
/// <summary> /// Maps the specified route template and sets default route values and constraints. /// </summary> /// <param name="routes">A collection of routes for the application.</param> /// <param name="name">The name of the route to map.</param> /// <param name="routeTemplate">The route template for the route.</param> /// <param name="defaults">An object that contains default route values.</param> /// <param name="constraints">A set of expressions that specify values for <paramref name="routeTemplate"/>.</param> /// <returns>A reference to the mapped route.</returns> public static IHttpRoute MapHttpRoute(this HttpRouteCollection routes, string name, string routeTemplate, object defaults, object constraints) { return(MapHttpRoute(routes, name, routeTemplate, defaults, constraints, handler: null)); }
/// <summary> /// Maps the specified route template. /// </summary> /// <param name="routes">A collection of routes for the application.</param> /// <param name="name">The name of the route to map.</param> /// <param name="routeTemplate">The route template for the route.</param> /// <returns>A reference to the mapped route.</returns> public static IHttpRoute MapHttpRoute(this HttpRouteCollection routes, string name, string routeTemplate) { return(MapHttpRoute(routes, name, routeTemplate, defaults: null, constraints: null)); }
public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix, IEdmModel model, IODataPathHandler pathHandler, IEnumerable <IODataRoutingConvention> routingConventions) { Extensions.HttpRouteCollectionExtensions.MapODataServiceRoute(routes, routeName, routePrefix, model, pathHandler, routingConventions); }
public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix, IEdmModel model, ODataBatchHandler batchHandler) { Extensions.HttpRouteCollectionExtensions.MapODataServiceRoute(routes, routeName, routePrefix, model, batchHandler); }
// Add generation hooks for the Attribute-routing subroutes. // This lets us generate urls for routes supplied by attr-based routing. private static void AddGenerationHooksForSubRoutes(HttpRouteCollection destRoutes, HttpRouteCollection sourceRoutes) { foreach (KeyValuePair <string, IHttpRoute> kv in sourceRoutes.GetRoutesWithNames()) { string name = kv.Key; IHttpRoute route = kv.Value; var stubRoute = new GenerateRoute(route); destRoutes.Add(name, stubRoute); } }
private static void AddRouteToRespondWithBadRequestWhenAtLeastOneRouteCouldMatch( string routeName, string routePrefix, HttpRouteCollection routes, List<ODataRoute> odataRoutes, List<IHttpRouteConstraint> unversionedConstraints ) { Contract.Requires( !IsNullOrEmpty( routeName ) ); Contract.Requires( routes != null ); Contract.Requires( odataRoutes != null ); Contract.Requires( unversionedConstraints != null ); var unversionedRoute = new ODataRoute( routePrefix, new UnversionedODataPathRouteConstraint( unversionedConstraints ) ); AddApiVersionConstraintIfNecessary( unversionedRoute ); routes.Add( routeName + UnversionedRouteSuffix, unversionedRoute ); odataRoutes.Add( unversionedRoute ); }
// Normal route table enumeration doesn't include the route name. internal static IEnumerable <KeyValuePair <string, IHttpRoute> > GetRoutesWithNames(this HttpRouteCollection routes) { KeyValuePair <string, IHttpRoute>[] names = new KeyValuePair <string, IHttpRoute> [routes.Count]; routes.CopyTo(names, 0); return(names); }
public static IHttpRoute MapHttpRoute(this HttpRouteCollection routes, string name, string routeTemplate, object defaults, string[] namespaces) { return(AfxRouteCollectionExtensions.MapHttpRoute(routes, name, routeTemplate, defaults, null, null, namespaces)); }