NancyFx/Nancy — pull request #1519 by liddellj (2014-04-25 15:22:38+00:00)
Title: Spiking out metadata module support

Spiking out support for metadata modules as part of #1486. This is a work-in-progress, but I'm opening up a PR to get feedback.

Given a `NancyModule` which defines a named route:
```csharp
public class ProductsModule : NancyModule
{
public ProductsModule() : base("products")
{
Get["GetAllProducts", "/"] = _ => "Here are the products";
}
}
```
If you define an `IMetadataModule` implementation alongside the module, following the naming convention below, then you can describe the named routes in more detail. A base class `MetadataModule` makes this easier to implement.
```csharp
public class ProductsMetadataModule : MetadataModule
{
public ProductsMetadataModule()
{
Describe["GetAllProducts"] = desc=>
{
return new MySuperRouteMetadata(desc.Method, desc.Path)
{
SuperDescription = "Returns the string \"Here are the products\""
};
};
}
}
```
The parameter passed to the delegate is of type `RouteDescription` - so you can access any of those properties in constructing the metadata to return. I've added an example to Nancy.Demo.Hosting.Aspnet.

`RouteCache` has been updated to obtain metadata from metadata modules in addition to metadata obtained from `IRouteMetadataProvider` implementations.

Note that there are no tests or docs for this stuff yet (in fact I've broken one of the tests for `ConfigurableBootstrapper` which I've not fixed yet). I've tried to follow existing conventions and patterns wherever possible.