Permalink
Browse files

Remove the catch all parsing code.

  • Loading branch information...
1 parent 54c0dfb commit b7b1371a2aa0d002ff33138bb0d20115c7f49da6 @davidfowl davidfowl committed Jan 4, 2013
@@ -8,10 +8,10 @@ public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
- routes.MapConnection<SendingConnection>("sending-connection", "sending-connection/{*operation}");
- routes.MapConnection<TestConnection>("test-connection", "test-connection/{*operation}");
- routes.MapConnection<RawConnection>("raw-connection", "raw-connection/{*operation}");
- routes.MapConnection<StreamingConnection>("streaming-connection", "streaming-connection/{*operation}");
+ routes.MapConnection<SendingConnection>("sending-connection", "sending-connection");
+ routes.MapConnection<TestConnection>("test-connection", "test-connection");
+ routes.MapConnection<RawConnection>("raw-connection", "raw-connection");
+ routes.MapConnection<StreamingConnection>("streaming-connection", "streaming-connection");
// Register the default hubs route: ~/signalr/hubs
routes.MapHubs();
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-using System;
using System.Diagnostics.CodeAnalysis;
-using System.Web.Routing;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using Microsoft.AspNet.SignalR.SystemWeb.Infrastructure;
@@ -53,16 +51,13 @@ public static class RouteExtensions
/// <param name="name">The name of the route</param>
/// <param name="url">path pattern of the route. Should end with catch-all parameter.</param>
/// <returns>The registered route</returns>
- /// <example>
- /// routes.MapConnection("echo", "echo/{*operation}", typeof(MyConnection));
- /// </example>
public static RouteBase MapConnection(this RouteCollection routes, string name, string url, Type type)
{
return MapConnection(routes, name, url, type, GlobalHost.DependencyResolver);
}
/// <summary>
- /// Initializes the default hub route (~/signalr).
+ /// Initializes the default hub route (/signalr).
/// </summary>
/// <param name="routes">The route table</param>
/// <returns>The registered route</returns>
@@ -72,18 +67,18 @@ public static RouteBase MapHubs(this RouteCollection routes)
}
/// <summary>
- /// Changes the dependency resolver for the default hub route (~/signalr).
+ /// Changes the dependency resolver for the default hub route (/signalr).
/// </summary>
/// <param name="routes">The route table</param>
/// <param name="resolver">The dependency resolver to use for the hub connection</param>
/// <returns>The registered route</returns>
public static RouteBase MapHubs(this RouteCollection routes, IDependencyResolver resolver)
{
- return MapHubs(routes, "~/signalr", resolver);
+ return MapHubs(routes, "/signalr", resolver);
}
/// <summary>
- /// Changes the default hub route from ~/signalr to a specified path.
+ /// Changes the default hub route from /signalr to a specified path.
/// </summary>
/// <param name="routes">The route table</param>
/// <param name="url">The path of the hubs route. This should *NOT* contain catch-all parameter.</param>
@@ -94,7 +89,7 @@ public static RouteBase MapHubs(this RouteCollection routes, string url)
}
/// <summary>
- /// Changes the default hub route from ~/signalr to a specified path.
+ /// Changes the default hub route from /signalr to a specified path.
/// </summary>
/// <param name="routes">The route table</param>
/// <param name="url">The path of the hubs route. This should *NOT* contain catch-all parameter.</param>
@@ -117,18 +112,10 @@ public static RouteBase MapHubs(this RouteCollection routes, string url, IDepend
throw new ArgumentNullException("resolver");
}
- var existing = routes["signalr.hubs"];
- if (existing != null)
- {
- routes.Remove(existing);
- }
-
- var routeUrl = url.TrimStart('~').TrimStart('/');
-
var locator = new Lazy<IAssemblyLocator>(() => new BuildManagerAssemblyLocator());
resolver.Register(typeof(IAssemblyLocator), () => locator.Value);
- return routes.MapOwinRoute("signalr.hubs", routeUrl, map => map.MapHubs(resolver));
+ return routes.MapOwinRoute("signalr.hubs", url, map => map.MapHubs(resolver));
}
@@ -143,15 +130,7 @@ public static RouteBase MapHubs(this RouteCollection routes, string url, IDepend
/// <returns>The registered route</returns>
public static RouteBase MapConnection(this RouteCollection routes, string name, string url, Type type, IDependencyResolver resolver)
{
- var routeUrl = url ?? String.Empty;
- var catchAllIndex = routeUrl.LastIndexOf("/{*", StringComparison.Ordinal);
- if (routeUrl.EndsWith("}", StringComparison.OrdinalIgnoreCase) && catchAllIndex != -1)
- {
- routeUrl = routeUrl.Substring(0, catchAllIndex);
- }
- routeUrl = routeUrl.TrimStart('~').TrimStart('/');
-
- return routes.MapOwinRoute(name, routeUrl, map => map.MapConnection(String.Empty, type, resolver));
+ return routes.MapOwinRoute(name, url, map => map.MapConnection(String.Empty, type, resolver));
}
}
}
@@ -56,16 +56,16 @@ public static void Start()
// Register the default hubs route: ~/signalr/hubs
RouteTable.Routes.MapHubs();
- RouteTable.Routes.MapConnection<MyBadConnection>("errors-are-fun", "ErrorsAreFun/{*operation}");
- RouteTable.Routes.MapConnection<MyGroupEchoConnection>("group-echo", "group-echo/{*operation}");
- RouteTable.Routes.MapConnection<MySendingConnection>("multisend", "multisend/{*operation}");
- RouteTable.Routes.MapConnection<MyReconnect>("my-reconnect", "my-reconnect/{*operation}");
- RouteTable.Routes.MapConnection<MyGroupConnection>("groups", "groups/{*operation}");
- RouteTable.Routes.MapConnection<MyRejoinGroupsConnection>("rejoin-groups", "rejoin-groups/{*operation}");
- RouteTable.Routes.MapConnection<FilteredConnection>("filter", "filter/{*operation}");
- RouteTable.Routes.MapConnection<ConnectionThatUsesItems>("items", "items/{*operation}");
- RouteTable.Routes.MapConnection<SyncErrorConnection>("sync-error", "sync-error/{*operation}");
- RouteTable.Routes.MapConnection<AddGroupOnConnectedConnection>("add-group", "add-group/{*operation}");
+ RouteTable.Routes.MapConnection<MyBadConnection>("errors-are-fun", "ErrorsAreFun");
+ RouteTable.Routes.MapConnection<MyGroupEchoConnection>("group-echo", "group-echo");
+ RouteTable.Routes.MapConnection<MySendingConnection>("multisend", "multisend");
+ RouteTable.Routes.MapConnection<MyReconnect>("my-reconnect", "my-reconnect");
+ RouteTable.Routes.MapConnection<MyGroupConnection>("groups", "groups");
+ RouteTable.Routes.MapConnection<MyRejoinGroupsConnection>("rejoin-groups", "rejoin-groups");
+ RouteTable.Routes.MapConnection<FilteredConnection>("filter", "filter");
+ RouteTable.Routes.MapConnection<ConnectionThatUsesItems>("items", "items");
+ RouteTable.Routes.MapConnection<SyncErrorConnection>("sync-error", "sync-error");
+ RouteTable.Routes.MapConnection<AddGroupOnConnectedConnection>("add-group", "add-group");
// End point to hit to verify the webserver is up
RouteTable.Routes.Add("test-endpoint", new Route("ping", new TestEndPoint()));

0 comments on commit b7b1371

Please sign in to comment.