NancyFx/Nancy — pull request #750 by prabirshrestha (2012-09-15 17:47:52+00:00)
Title: added overload for INancyEngine taking Func<NancyContext, NancyContext>

Added HandlRequest in INancyEngine taking preRequest Func.
``` csharp
void HandleRequest(Request request, Func preRequest, Action onComplete, Action onError);
```

I added it as an overload as per @Grumpydev request so there would be no breaking change in Nancy https://groups.google.com/forum/?fromgroups=#!topic/nancy-web-framework/ebKfk3Gxe2k

This now allows the host to modify the NancyContext without creating a wrapper for INancyContext factory.

This can be very useful for Owin Host. Owin host can now pass the owin environment to `NancyContext.Items["owin"]`. This means nancy apps can take advantage of owin extensions such as WebSockets extension without waiting for WebExtensions to be actually supported by Nancy. This will also allow the possibilities of using OWIN middlewares in Nancy.

I'm sending this as a separate PR. Once this is merged, I can rebase it onto my owin15 PR #730. If you would like to see the merged one you can find it in https://github.com/prabirshrestha/Nancy/tree/owin15-preRequest

Here is how one could then access the owin environment.

```csharp
Get["/owin"] = x =>
{
var owinEnvironment = (IDictionary)Context.Items["owin"];

return "Method = " + (string)owinEnvironment["owin.RequestMethod"];
};
```

/cc @loudej @Tratcher