Windsor Bootstrapper for Nancy
This is a bootstrapper for using Windsor with Nancy. A couple of things are worth noting about this bootstrapper that differ from the others. First, child containers are a bit of a faux paux with Windsor (if you are really interested you can read a bit about it here, here and here) personally I don't fully understand why, but I've found it is virtually impossible to avoid a memory leak if you are creating one for each request.
Fortunately Windsor has something that is better than child containers, a
PerWebRequestLifestyle which automagically disposes of instances when the web request ends. Unfortunately it only works with ASP.NET.
This really isn't a problem. This bootstrapper uses a hybrid lifestyle that falls back to a strictly transient lifecycle which seems to behave well and should work with things like the built in Nancy self hosting (probably should get more testing than I've given it though). For anyone using ASP.NET or WCF this will work very well.
You will need to add the following module to your web config however:
<httpModules> <add name="PerWebRequest" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule" /> </httpModules> <modules runAllManagedModulesForAllRequests="true"> <add name="PerWebRequest" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule" /> </modules>
If you ave any problems feel free to report bugs here on Github and I will fix them ASAP (it's in my own intrest since I'm using this for work). Even better would be a pull request with a test ;-).
Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors
Nancy.Bootstrappers.Windsor is licensed under MIT. Refer to license.txt for more information.