Skip to content

Instantly share code, notes, and snippets.

@darrelmiller
Created April 14, 2014 20:56
Show Gist options
  • Save darrelmiller/10682188 to your computer and use it in GitHub Desktop.
Save darrelmiller/10682188 to your computer and use it in GitHub Desktop.
Create an AppFunc for a WebApi application
public static Func<IDictionary<string, object>, Task> CreateWebApiAppFunc(HttpConfiguration config)
{
var app = new HttpServer(config);
var options = new HttpMessageHandlerOptions()
{
MessageHandler = app,
BufferPolicySelector = new OwinBufferPolicySelector(),
ExceptionLogger = new WebApiExceptionLogger(),
ExceptionHandler = new WebApiExceptionHandler()
};
var handler = new HttpMessageHandlerAdapter(null, options);
return (env) => handler.Invoke(new OwinContext(env));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment