Simple URI builder for named Nancy routes with optional pass through of query parameters.
PM> Install-Package Nancy.Linker
public class BazModule : NancyModule
{
public BazModule(IResourceLinker linker)
{
var absoluteLink = linker.BuildAbsoluteUri(this.Context, "aNamedRoute", parameters: new {id = 123})
var relativeLink = linker.BuildRelativeUri(this.Context, "aNamedRoute", parameters: new {id = 123})
}
}
To enable the query parameters pass through filter, bootstrap the PassthroughQueryFilter class. In the code below, the parameter 'foo' will be passed to the build URI from the ResourceLinker.
public class Bootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
// Other bootstrapper code here
container.Register<IQueryFilter>(new PassthroughQueryFilter(new[] { "foo" }));
}
}