Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

A Brief History of OWIN

1,369 views

Published on

Discussion of the history and evolution of the Open Web Interface for .NET (OWIN).

Published in: Technology
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

A Brief History of OWIN

  1. 1. 0 A Brief History of OWIN Ryan Riley
  2. 2. Welcome to Houston TechFest • Please turn off all electronic devices or set them to vibrate. • If you must take a phone call, please do so in the lobby so as not to disturb others. • Thanks to our Diamond Sponsors: Thank you for being a part of the 9th Annual Houston TechFest!
  3. 3. 2 Please Leave Feedback During Q&A If you leave session feedback and provide contact information in the survey, you will be qualified for a prize Scan the QR Code to the right or go to http://bit.ly/1K1Hvi5
  4. 4. 3 Ryan Riley • Engineer at Tachyus • OWIN Management Committee • ASPInsider • Visual F# MVP • Leads Community for F#
  5. 5. 4 Click to edit Master title style Why OWIN? Open Web Interface for .NET
  6. 6. 5 Click to edit Master title style Problem: Desire for Fast and Light-weight Frameworks and Servers ASP.NET was “too heavy” IIS was “too slow” ASP.NET was coupled to IIS Hard to do REST
  7. 7. 6 Solutions • Boat • Figment • Fracture • Frank • FubuMVC • KayakHTTP • NancyFx • Nina • NRack • OpenRasta • Suave • WCF Web API (later ASP.NET Web API) • Among others
  8. 8. 7 Click to edit Master title style Problem: Repetition Sinatra in .NET ASP.NET adapters Self-host adapters (esp. HttpListener)
  9. 9. 8 Solution: Collaborate http://despair.com/products/collaboration
  10. 10. 9 September 7, 2010 I’ve noticed a trend recently in projects each of us has worked/is working on and wondered if we might be willing to pool our resources.... If you are interested in working together, please let me know.... I’m sure we could agree on a common platform for our efforts. - Email from Ryan Riley (Frank) to Benjamin van der Veen (KayakHTTP), Mauricio Scheffer (Figment), and Scott Koon (Boat)
  11. 11. 10 September 27, 2010 Benjamin van der Veen submits first draft of interfaces public interface IHttpResponder { IObservable<IHttpServerResponse> Respond( IHttpServerRequest request, IDictionary<string, object> context ); } public interface IHttpServerRequest { HttpRequestLine RequestLine { get; } IDictionary<string, string> Headers { get; } IObservable<ArraySegment<byte>> GetBodyChunk(); } public interface IHttpServerResponse { HttpStatusLine StatusLine { get; } IDictionary<string, string> Headers { get; } string BodyFile { get; } IObservable<ArraySegment<byte>> GetBodyChunk(); }
  12. 12. 11 November 29, 2010 Scott Koon creates .NET HTTP Abstractions • Now called OWIN Working Group • https://groups.google.com/forum/#!forum/ net-http-abstractions
  13. 13. 12 Click to edit Master title style Problem: Opinions and Existing Implementations
  14. 14. 13 Solution: Define a Common Interface • Rack (Ruby) • WSGI (Python)
  15. 15. 14 Consensus to share server wrappers
  16. 16. 15 Progress! • Name: Open Web Interface for .NET (OWIN) • Began writing specification • BHAG: run ASP.NET MVC on top
  17. 17. 16 Click to edit Master title style Problem: Trouble in Paradise
  18. 18. 17 Solutions Factions • Which interfaces / types? • Require a library dependency? • OOP vs FP • Static vs Dynamic typing Solutions • Only types from the FCL • No library dependency • Delegates + • IDictionary<string, object>
  19. 19. 18 Click to edit Master title style Problem: How to represent async access to the message body?
  20. 20. 19 Proposed Solution #1: System.IO.Stream • Considered “too heavy” as an interface • Async access considered “too slow” due to APM model • Rejected
  21. 21. 20 Proposed Solution #2: System.IObservable<T> • Concerned about back-pressure • Required library dependency for .NET 3.5 • Rejected
  22. 22. 21 Proposed Solution #3: Task • Required (then new) .NET 4.0 • Some contributors had an established .NET 3.5 user base • Rejected
  23. 23. 22 Proposed Solution #4: “Delegate of Doom” public delegate void AppDelegate( IDictionary<string, object> env, ResultDelegate result, Action<Exception> fault); public delegate void ResultDelegate( string status, IDictionary<string, IEnumerable<string>> headers, BodyDelegate body); public delegate void BodyDelegate( Func<ArraySegment<byte>, bool> write, Func<Action, bool> flush, Action<Exception> end, CancellationToken cancellationToken); • Accepted!
  24. 24. 23 Click to edit Master title style Problem: “Delegate of Doom” difficult to implement
  25. 25. 24 Solution: Gate reference / helper library Image from “The Reality of a Developer's Life - in GIFs, Of Course”
  26. 26. 25 Click to edit Master title style WIN: SignalR chooses OWIN!
  27. 27. 26 Click to edit Master title style Problem: SignalR not compatible with “Delegate of Doom”
  28. 28. 27 Single Tap • SignalR • ASP.NET • Fubu MVC • Razor • node.js
  29. 29. 28 Double Tap • OWIN (with “Delegate of Doom”) • ASP.NET Web API • Frank • NancyFX • Rack (Ruby)
  30. 30. 29 Solution using Environment = IDictionary<string, object> using AppFunc = Func<Environment, Task>
  31. 31. 30 Task? • Accepted on August 22, 2012 • 2 years makes a big difference
  32. 32. 31 The OWIN Specification http://owin.org/html/owin.html 1. Overview 2. Definitions 3. Request Execution 3.1. Application Delegate 3.2. Environment 3.3. Headers 3.4. Request Body 3.5. Response Body 3.6. Request Lifetime 4. Application Startup 5. URI Reconstruction 5.1. URI Scheme 5.2. Hostname 5.3. Paths 5.4. URI Reconstruction Algorithm 5.5. Percent-encoding 6. Error Handling 6.1. Application Errors 6.2. Server Errors 7. Versioning
  33. 33. 32 Request Keys • owin.RequestBody : Stream • owin.RequestHeaders : IDictionary<string, string[]> • owin.RequestMethod : string • owin.RequestPath : string • owin.RequestPathBase : string • owin.RequestProtocol : string • owin.RequestQueryString : string • owin.RequestScheme : string • owin.RequestId* : optional string • owin.RequestUser* : optional ClaimsPrincipal
  34. 34. 33 Response Keys • owin.ResponseBody : Stream • owin.ResponseHeaders : IDictionary<string, string[]> • owin.ResponseStatusCode : optional int (default is 200) • owin.ResponseReasonPhrase : optional string (default set by server) • owin.ResponseProtocol : optional string
  35. 35. 34 Other Data • owin.CallCancelled : CancellationToken • owin.Version : string
  36. 36. 35 Using AppFunc using System.IO; using System.Text; using Headers = IDictionary<string, string[]>; var app = AppFunc(env => { var bytes = Encoding.UTF8.GetBytes("Hello, OWIN!"); var length = bytes.Length.ToString(); var headers = (Headers)env.["owin.ResponseHeaders"]; headers.Add("Content-Type", new[] { "text/plain" }); headers.Add("Content-Length", new[] { length }); var stream = (Stream)env.["owin.ResponseBody"]; return stream.WriteAsync(bytes, 0, bytes.Length); });
  37. 37. 36 Flexibility: AppFunc as a Class public class MyApp { public Task Invoke(Environment env) { var bytes = Encoding.UTF8.GetBytes("Hello, OWIN!"); var length = bytes.Length.ToString(); var headers = (Headers)env.["owin.ResponseHeaders"]; headers.Add("Content-Type", new[] { "text/plain" }); headers.Add("Content-Length", new[] { length }); var stream = (Stream)env.["owin.ResponseBody"]; return stream.WriteAsync(bytes, 0, bytes.Length); } }
  38. 38. 37 Flexibility: AppFunc as a Method public class MyApps { public Task MyApp1(Environment env) { // uses state from MyApps } public static Task MyApp2(Environment env) { // does not use MyApps’ state } }
  39. 39. 38 AppFunc Composition public static class Logging { public static Task LogBefore(Environment env) { /**/ } public static Task LogAfter(Environment env) { /**/ } public static ???? Log(????) { LogBefore(env); // call something else, but how? LogAfter(env); } }
  40. 40. 39 Middleware using MidFunc = Func<AppFunc, AppFunc>; public static class Logging { public static Task LogBefore(Environment env) { /**/ } public static Task LogAfter(Environment env) { /**/ } public static AppFunc Log(AppFunc next) { return async env => { LogBefore(env); await next(env); LogAfter(env); }; } }
  41. 41. 40 Middleware as a Class public class Logging { AppFunc next; public Logging(AppFunc next) { this.next = next; } static Task LogBefore(Environment env) { /**/ } static Task LogAfter(Environment env) { /**/ } public async Task Invoke(Environment env) { LogBefore(env); await this.next(env); LogAfter(env); } }
  42. 42. 41 OO AppFunc Composition public class Startup { private readonly AppFunc composed; public Startup(AppFunc next) { this.composed = Logging.Log(next); } public Task Invoke(Environment env) { return this.composed(env); } }
  43. 43. 42 Functional AppFunc Composition public static class Startup { static readonly AppFunc next = ...; static readonly AppFunc composed = Logging.Log(next); public static Task Invoke(Environment env) { return Startup.composed(env); } }
  44. 44. 43 Goals Achieved No dependencies Flexibility of style Server independence
  45. 45. 44 Bonus! Simple composition Can construct dynamic execution graphs* No server required (easy to unit test)
  46. 46. 45 Click to edit Master title style Push to 1.0
  47. 47. 46 Microsoft and others adopt OWIN • Microsoft.Owin, a.k.a. Katana • Fix • Freya • SimpleOwin • Simple.Owin • Suave • WebSharper
  48. 48. 47 Server Support • System.Web • HttpListener • IIS (Helios) • Nowin (cross-platform) • Suave (cross-platform)
  49. 49. 48 Middleware • CORS • Security • Routing (Superscribe) • Diagnostics • Many more!
  50. 50. 49 Put It All Together // Using Microsoft.Owin public class Startup { public void Configuration(IAppBuilder app) { app.Properties["host.AppName"] = "composed app"; app.UseCors(Cors.CorsOptions.AllowAll) .MapSignalR() .UseWebApi(new HttpConfiguration()) .UseNancy(); } }
  51. 51. 50 Artifact: owin.dll • Originally intended to provide the delegate signatures • IAppBuilder was later added and left as the only interface • IAppBuilder was not spec’d and had no connection to AppFunc public interface IAppBuilder { IDictionary<string, object> Properties { get; } IAppBuilder Use(object middleware, params object[] args); object Build(Type returnType); IAppBuilder New(); }
  52. 52. 51 Click to edit Master title style Moving Forward
  53. 53. 52 OWIN Management Committee • Established governance model • Converted specs to Markdown (https://github.com/owin/owin) • GitHub Issues to submit and vote on changes (https://github.com/owin/owin/issues)
  54. 54. 53 Formalized Middleware Signature • Specification in draft using MidFunc = Func<AppFunc, AppFunc> using MidFactory = Func< IDictionary<string, object>, // startup properties MidFunc // outer Middleware > using BuildFunc = Action<MidFactory>
  55. 55. 54 BHAG: ASP.NET vNext and MVC 6 • Achievement unlocked … • … sort of
  56. 56. 55 Two Steps Back (Step 1) https://twitter.com/jchannon/status/641312171918553088
  57. 57. 56 ASP.NET 5 and DNX Support public void Configure(IApplicationBuilder app) { app.UseCookieAuthentication(options => { options.AutomaticAuthentication = true; options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme; }); app.UseTwitterAuthentication(configureOptions => { configureOptions.ConsumerKey = TWITTERCONSUMERKEY; configureOptions.ConsumerSecret = TWITTERSECRET; }); app.UseOwin(x => x.UseNancy()); }
  58. 58. 57 Two Steps Back (Step 2) Different opinions about: • Discovery, i.e. IAppBuilder • Middleware
  59. 59. 58 Katana-style Middleware • “Soft 404” • Linear pipeline set at compile time • Possible to branch using IAppBuilder.Map
  60. 60. 59 Dynamic Pipeline • Techniques used by Damian Hickey and Sebastian Lambla • Middleware builds and executes its own pipeline • Can change during runtime • See an example
  61. 61. 60 Graph-based Execution • Superscribe – routing • Freya – web machine
  62. 62. 61 Verdict: Middleware Wins • Still more ideas to try out! • What are yours?
  63. 63. 62 Questions?
  64. 64. 63 Get Involved! • Submit your feedback on the specs • Help us with governance • Propose and vote on next steps • http://owin.org/ • https://github.com/owin/owin/issues • http://groups.google.com/group/net-http-abstractions
  65. 65. Please Leave Feedback During Q&A If you leave session feedback and provide contact information in the survey, you will be qualified for a prize Scan the QR Code to the right or go to http://bit.ly/1K1Hvi5
  66. 66. Thanks to all our Sponsors!

×