I have a sample application that shows how to host Nancy on node.js.
To do that I need to change the rootpath. I ended up with something like that:
public class Startup
{
public static void Configuration(IAppBuilder app)
{
string rootpath = app.Properties["node.rootpath"] as string;
app.UseNancy(options => options.Bootstrapper = new NodeBootstrapper(rootpath));
}
}
public class NodeRootPathProvider : IRootPathProvider
{
private string rootpath;
public NodeRootPathProvider(string rootpath)
{
this.rootpath = rootpath;
}
public string GetRootPath()
{
return this.rootpath;
}
}
public class NodeBootstrapper : DefaultNancyBootstrapper
{
private string rootpath;
public NodeBootstrapper(string rootpath)
: base()
{
this.rootpath = rootpath;
}
protected override IRootPathProvider RootPathProvider
{
get { return new NodeRootPathProvider(this.rootpath); }
}
}
Is there a way to simplfy this?