NancyFx/Nancy.Bootstrappers.Windsor — pull request #12 by Lodewijk-S (2013-06-27 16:41:54+00:00)
Title: Fix Castle Windsor Bootstrapper under Owin

Solution for issue #5

The problem with the current implementation of Windsor for Nancy was that the code that intercepted the call to HandleRequest wrapped the wrong HandleRequest call when working on Owin. This caused the WindsorScope to be disposed while the request was still being handled on another thread.

I implemented Windsor in a slightly different way. Since Windsor ask to Release everything you Resolve, I wrapped the modules in an IDisposable when they are resolved. That wrapped module is then stored in the NancyContext, which automatically disposes all IDisposables. That way the module is Released when it is no longer needed.

You can scope your dependencies per webrequest by using `.LifestyleBoundToNearest()` when registering your dependencies.

Todo:
- [ ] Update documentation
- [ ] Code review