Simple URI builder for named Nancy routes
C#
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

Nancy.Linker NuGet Status License Build status

Simple URI builder for named Nancy routes with optional pass through of query parameters.

Installation

PM> Install-Package Nancy.Linker

General Usage

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})
  }
}

Query Parameter Passthrough Usage

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" }));
  }
}

More information

On My Blog

http://www.horsdal-consult.dk/search/label/Nancy.Linker

On Other Blogs

http://codeopinion.com/nancy-linker-nancyfx-uri-builder/