Reputation: 3495
Inside of my bootstrapper I have:
protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) {
base.ApplicationStartup(container, pipelines);
pipelines.BeforeRequest.AddItemToStartOfPipeline (ctx =>
{
var parameters = ctx.Parameters;
var resolver = ctx.ResolvedRoute;
return null;
});
}
Unfortunately it seems that when making a request on an url like "http://localhost:3579/thingy/123", which matches a route "/thingy/{thingyId}" both ctx.Parameters and ctx.ResolvedRoute are null, even in AddItemToEndOfPipeline.
Don't ask me why, but I need to do come fiddling using this route parameter before many different sub routes, but can't find a way to access it. Anyone know a way?
Upvotes: 1
Views: 794
Reputation: 3495
I did it :)
protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) {
base.ApplicationStartup(container, pipelines);
pipelines.BeforeRequest.AddItemToStartOfPipeline (ctx =>
{
var resolver = container.Resolve<IRouteResolver>();
var route = resolver.Resolve(ctx);
var thingyId = route.Parameters["thingyId"];
return null;
});
}
Upvotes: 2