This project has moved and is read-only. For the latest updates, please go here.

HttpListener ServerFactory

Sep 22, 2012 at 2:29 AM
Edited Sep 22, 2012 at 6:57 AM

I am building a new framework that will sit atop of owin and I am playing around with the HttpListener adapter.  Which leads me to the following questions:

Why are there two distinct methods to start the server via the Factory?

Why is the factory abstraction even necessary?  

Why does the factory return IDisposable instead of the Server? 

The api usability is tad cumbersome with this approach. Ideally, I would like to start a server as follows: 

var app = new AppBuilder();
var server = new OwinHttpListener(app);

// at some point in the future, I would leverage the dispose pattern or call stop directly.




Sep 25, 2012 at 6:32 PM
Edited Sep 25, 2012 at 6:32 PM

The ServerFactory pattern helps remove the dependency between the Host.exe and the Server API.  You can drop in the dll for another owin server and not even re-compile the host.  IDisposable is used as the return value for the same reason.

ServerFactory.Initialize allows the server to announce what features it supports.  The application can inspect this list and configure the server, pipeline, and application accordingly.

The full startup process is as follows:

- Startup the Host container

- Find the server, call Initialize

- Find the application, call Configure

- Call Create on the server


Are you a member of the OWIN discussion group?

~Chris R

Feb 18, 2013 at 7:57 PM