Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nancy redirect to route under the current module

Tags:

nancy

I need to redirect to a path under the current module:

modulePath = "/test";  
Get["/there"] = ...  
Get["/here"] = routeParams => { return ????????????("/there"); } 

I expect "/test/here" to redirect to "/test/there"

like image 727
Sabin Neagu Avatar asked Jul 08 '14 12:07

Sabin Neagu


1 Answers

You can use named routes and Nancy.Linker. See https://github.com/horsdal/Nancy.Linker

That is install Nancy.Linker from NuGet, take a dependency on IResourceLinker and change the code to:

public class YourModule
{
    public YourModule(IResourceLinker linker)
    {
        Get["theRoute", "/there"] = ...  
        Get["/here"] = Response.AsRedirect(linker.BuildAbsoluteUri(this.Context, "theRoute");
    }
{
like image 199
Christian Horsdal Avatar answered Sep 27 '22 21:09

Christian Horsdal