-
Notifications
You must be signed in to change notification settings - Fork 4
Routing
Routing is controlled via [Handle]
attributes on the Handlers:
[Handle("/some/path")]
sealed class SomePathHandler : Handler
{
}
Routing is performed in a similar way to System.Web.Routing
, however there are no default route values (these aren't necessary, our Model Binder works).
A Handler can have multiple Handle
attributes, however the order you place them in the handler .cs file is not obeyed and therefore shouldn't be relied on.
We don't use any broad, ASP.NET MVC style routes which cover many handlers e.g. /{controller}/{action}/{id}
. Each handler has its own, specific route defined. Only parameters specific to the handler are varied per route.
[Handle("/some/path")]
[Handle("/some/other/path")]
sealed class SomePathHandler : Handler
{
}
Two handlers can handle the same route, although they should not both handle the same HTTP Methods, as there is no guarantee which one will be hit:
[Handle("/some/path")]
sealed class SomePathGetHandler : Handler
{
public IResult Get()
{
// ...
}
}
[Handle("/some/path")]
sealed class SomePathPostHandler : Handler
{
public IResult Post()
{
// ...
}
}
Routes can also contain parameters, which are made available to the HTTP Method handling methods though Binding:
[Handle("/some/path/{foo}")]
sealed class SomePathHandler : Handler
{
public IResult Get(string foo)
{
// ...
}
}
TODO