Inspired by the rails routing api.
Available via NuGet.
PM> Install-Package RestfulRouting
Checkout out the new documentation site included in this project, which can be found hosted at restfulrouting.com. If you find any improvements that need to be made, please feel free to contact us or send a pull request.
Basic usage:
public class Routes : RouteSet
{
public override void Map(Mapper map)
{
map.Root<HomeController>(x => x.Show());
map.Path("test/{id}").To<TestController>(x => x.Test()).Constrain("id", @"\d+");
map.Resource<SessionsController>();
map.Resources<BlogsController>(blogs =>
{
blogs.As("weblogs");
blogs.Only("index", "show");
blogs.Collection(x => {
x.Get("latest");
x.Post("someaction");
);
blogs.Member(x => x.Put("move"));
blogs.Resources<PostsController>(posts =>
{
posts.Except("create", "update", "destroy");
posts.Resources<CommentsController>(c => c.Except("destroy"));
});
});
}
}
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RestfulRoutingViewEngine());
RouteTable.Routes.MapRoutes<Routes>();
}
}
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don’t break it in a
future version unintentionally. - Send me a pull request. Bonus points for topic branches.
Written by Steve Hodgkiss with contributions from
1.3.0
- Removed dependency on RazorEngine so we can start moving to ASP.Net MVC 4.
1.2.3
- Fixed float parsing on systems with decimal separator other than “.” (thanks irium)
1.2.2
- Fixes ordering issue with Only (thanks Tommysqueak)
- Fixes StandardMapper to use RestfulHttpMethodConstraint (thanks Tommysqueak)
- Fixed version number on dll to match version number of Restful Routing
1.2.0
- Addition of ExposeResult in FormatResult (thanks SlyNet)
1.1.3
- New Route Debugger (uses datatables for filtering)
- Mono Fixes (thanks cdroulers)
- Released version to Nuget