private Response RunCassetteRequestHandler(NancyContext context) { logger.Debug("RunCassetteRequestHandler starting"); currentContext.Value = context; // Some parts of WebHost initialization require a valid NancyContext, so defer // creation of the WebHost until the first request hits the pipeline. if(webHost == null) { logger.Debug("WebHost is null, acquiring lock..."); lock (webHostLocker) { logger.Debug("I have the lock..."); if (webHost == null) { logger.Debug("I have the lock and webHost is still null. Creating/initing it..."); webHost = new WebHost(rootPathProvider, () => currentContext.Value); webHost.Initialize(); logger.Debug("...finished creating/initing webHost."); } } } logger.Debug("RunCassetteRequestHandler - running request handler."); return webHost.RunCassetteRequestHandler(context); }
private void EnsureWebHost(NancyContext context) { currentContext.Value = context; // Some parts of WebHost initialization require a valid NancyContext, so defer // creation of the WebHost until the first request hits the pipeline. if (webHost == null) { webHost = new WebHost(rootPathProvider, () => currentContext.Value); webHost.Initialize(); } }
private Response RunCassetteRequestHandler(NancyContext context) { currentContext.Value = context; // Some parts of WebHost initialization require a valid NancyContext, so defer // creation of the WebHost until the first request hits the pipeline. if(webHost == null) { webHost = new WebHost(rootPathProvider, () => currentContext.Value); webHost.Initialize(); } return webHost.RunCassetteRequestHandler(context); }