TopMenu

Basics of OWIN and Katana – Part I

OWIN
A community owned standard knows as OWIN or Open Web Interface for .Net is a standard interface between .NET web servers and web applications. The goal of OWIN is to decouple server and application and, by being an open standard, stimulate the open source ecosystem of .NET web development tools. OWIN is defined in terms of a delegate structure.

As per the sources from Asp.net website, the OWIN was inspired by the benefits achieved by Rack  in the Ruby community, several members of the .NET community set out to create an abstraction between Web servers and framework components. An overview of the components of abstraction can be visualized as:

image
Components of this abstraction:
Server – The HTTP server that directly communicates with the client and then uses OWIN semantics to process requests.  Servers may require an adapter layer that converts to OWIN semantics.

Web Framework – A self-contained component on top of OWIN exposing its own object model or API that applications may use to facilitate request processing.  Web Frameworks may require an adapter layer that converts from OWIN semantics.

Web Application – A specific application, possibly built on top of a Web Framework, which is run using OWIN compatible Servers.

Middleware – Pass through components that form a pipeline between a server and application to inspect, route, or modify request and response messages for a specific purpose.

Host – The process an application and server execute inside of, primarily responsible for application startup. Some Servers are also Hosts.

As a benefit of this abstraction you’ll be able to port or move your application from one server to other or Porting to completely different platform and OS(Host). Let’s visualize this in terms of technology existed on each layer. Now the diagram would become something like this: (Thanks to Lex Li to make it simple to understood for others here).

image

The resulting abstraction consists of two core elements. The first is the environment dictionary of type IDictionary<string, object>. This data structure is responsible for storing all of the state necessary for processing an HTTP request and response, as well as any relevant server state.
For full list of Dictionary items visit the specification here(see section 3.2).

The second key element of OWIN is the application delegate. This is a function signature which serves as the primary interface between all components in an OWIN application. The definition for the application delegate is as follows:
Func<IDictionary<string, object>, Task>;

Project Katana
The OWIN is a standard and the Katana is the project from Microsoft that represents the set of OWIN components. These components include both infrastructure components, such as hosts and servers, as well as functional components, such as authentication components and bindings to frameworks such as SignalR andASP.NET Web API. The project targets the following three goal as specified on Asp.net website page of Katana project:
1. Portable
2. Modular/Flexible
3. Lightweight/performant/scalable

Why Katana?
Katana was developed to be a light weight webserver like Node.js and it bring many benefits of Node.js and other frameworks like Node.js. If you know Node.js you can directly jump in taking hands on with Katana as it is inspired by Node.js in nature.

In the next post we will see how to create a simple application using the Katana and will discuss a little more about Katana.

No comments:

Post a Comment