WIP! - This is still in it's very early stages and far from done. - Ideas and Contributions are still more than wellcome though!...
The main features are:
- Define Routes in a Fluent Syntax
- Define Routes that point to Functions rather than Controllers.
Adding the services:
services.AddFluentRouting();
Simple Routing to Controllers:
app.UseFluentRouter(router => {
router.Route("api/stuff/{parameter?}").To<MyController>();
});
Minimal Hello World Route:
app.UseFluentRouter(router => {
router.Route("hello").To(() => "Hello World");
});
HttpContext Hello World Route:
app.UseFluentRouter(router => {
router.Route("hello").To(context => context.Request.Method + ": Hello World");
});
Parameters:
app.UseFluentRouter(router => {
router.Route("hello/{type}/{id}")
.To((FromRoute<string> type, FromRoute<int> id) => $"Fetch: {type} with id: {id}");
});
Services:
// Inject Service into Service Container...
interface IMyService {
MyStuff Fetch(string type, int id);
}
app.UseFluentRouter(router => {
router.Route("hello/{type}/{id}")
.To((FromRoute<string> type, FromRoute<int> id, FromService<IMyService> service) => {
return ((TService)service).Fetch(type, id);
});
});