Friday, August 2, 2013

OWIN and the Katana Project

OWIN

OWIN (a.k.a. Open Web Interface for .NET) is a new way of processing HTTP requests in .NET.  It is a specification describing how .NET web servers and .NET applications should interface and interact. The idea is that by decoupling the server and application we are able to write code independent of the host platform.  Our code at that point can be host agnostic and allow us much more flexibility on our chosen publishing environment.

IIS currently does double duty by handling both the host and server responsibilities.  To be clear, by host duties, I mean the process management, and by server, I mean network management and request handling.  This means that we as developers have to use packages specific to IIS suck as HttpModules, HttpHandlers, etc.  While this is effective, it makes our application tightly coupled to a specific hosting environment.  So, if we would want to target something a little more small to host a WebAPI, we would be out of luck.  OWIN gives us the ability to decouple those two things which gives us the flexibility to choose components based on individual functions while selecting only the ones we need and substituting only the ones that are actually different across hosting platforms. All of those changes would actually take place beneath the application.  Hm.. where have I seen this kind of thing before?

The way I understand it, a server in OWN is made up of an environment dictionary, of the form IDictionary<string, object>, used for holding the request processing state: things like the request path, the headers collection, the request bits themselves, and a delegate, of the form Func<IDictionary<string, object>, Task>, which is used to model how the components appear to each other.  This means that an app is a list of those components executed in sequence, each of those awaiting the next and passing the environment dictionary to each other.  This seems very dynamic and portable, which is a really strong position for a WebAPI or other hosted service. 

Katana Project

Katana is a set of components by Microsoft for building and hosting OWIN-based web applications.  Katana has host, server, and middleware source code and documentation located here. These tools are available via NuGet.  These products are actively developed by the Katana team assigned to the Microsoft Open Tech Hub and in collaboration with a community of open source developers.

3 comments: