无论模块还是路由,我都希望在每个请求中都做一些事情。如何在Nancy 2.x中完成此操作?
如果找到How to Intercept all Nancy requests和How do I capture all requests irrespective of verb or path,但它们仅适用于Nancy 1.x,并且Documentation已过期。
您可以尝试这个:
public class NewBootstrapper : DefaultNancyBootstrapper
{
protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context)
{
//Your code here
base.RequestStartup(container, pipelines, context);
}
}