Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

horsdal/Nancy.Linker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/