A simple tool for lazily bootstrapping any nodejs app into each application context.
contextualize creates an http server for you and provides a mechanism for defining the context for each request, and a mechanism for bootstrapping an application for each unique context.
var contextualize = ;;
Here is an example of how you might switch contexts based on environment and locale code in the host name:
By default the first request in a context will take the hit of bootstrapping the application for that context. If you want to
preload known contexts to avoid that latency on the first request then you can use the
You may want to apply some middleware (e.g. static file serving, cookie parsing, body parsing, user authentication, etc.) prior to setting the context for a request.
// Attach middleware here;
Applications returned by your bootstrap function are either a
Function or an
Object with a
Note that express and connect applications are already functions with this interface so this will work as well: