owin/gate — pull request #46 by kevinswiber (2011-11-10 01:51:40+00:00)
Title: Added Static middleware and supporting classes.

There are a lot of additions in here.

Some points:

* One thing you'll want to look at is the BodyStream class. It's used by the FileBody and TextBody classes. BodyStream inherits StateMachine, which has some nice support for transition mapping and command eavesdropping. This helped me figure out the differences between Kayak and ASP.NET host handlers recently. It is, however, a re-implementation of some convenience methods on the Body class. I'm not sure it's a complexity you want to take on, but I think it's worth it.

* Static uses FileServer to handle the bulk of the file handling.

* FileServer is written with future Sendfile middleware in mind, though this might take a different form when it finally materializes.

* File contents are currently streamed in 64KB buffers. I looked at some prior art for this. Rack sends 8KB chunks. Connect (via Node.js) sends 64KB chunks. I went high.

* Gate.Middleware took a dependency on Gate.Helpers.

* Static is built to take a directory as its root and a white-list of URL's. In the absence of this configuration (Static.Create()), it defaults to the "public" directory and marks all directories and files underneath as white-listed.

Note: This is mostly a move over from NRack to Gate with the exception of the BodyStream, which was created to specifically to track state of the OWIN body delegate.

Curious to see some feedback.