Middleware

83 views
Skip to first unread message

Ryan Riley

unread,
Mar 7, 2013, 7:50:09 AM3/7/13
to .NET HTTP Abstractions
Is it possible to wrap an existing Web API middleware and expose it as an OWIN middleware? I thought we talked about this some time in the past, but I no longer recall clearly. It sounds terribly un-performant.

Ryan

Chris R

unread,
Mar 7, 2013, 10:34:12 AM3/7/13
to net-http-a...@googlegroups.com
It was possible in previous versions of OWIN with the double-tap signature.  Less so with OWIN 1.0.

Transitioning into System.Net.Http is slightly expensive because you have to copy all the headers. Transitioning out again wouldn't be as bad because you could just use a facade over the existing structures.  Unfortunately if you did end up transitioning back out, you'd have to buffer the response body.

WebApi works fine as a pipeline branch, possibly even with soft-404 fall-through, but less good as a strait up middleware.


From: ryan....@panesofglass.org
Date: Thu, 7 Mar 2013 06:50:09 -0600
Subject: Middleware
To: net-http-a...@googlegroups.com


Is it possible to wrap an existing Web API middleware and expose it as an OWIN middleware? I thought we talked about this some time in the past, but I no longer recall clearly. It sounds terribly un-performant.

Ryan

--
You received this message because you are subscribed to the Google Groups ".NET HTTP Abstractions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-http-abstrac...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Louis DeJardin

unread,
Mar 7, 2013, 11:06:09 AM3/7/13
to Ryan Riley, .NET HTTP Abstractions
Yeah we did. It's possible to do, of course, but like you say there would be some work at the transitions. Although you could avoid recreating the httprequestmessage multiple times, that still leaves concerns: you'd be creating a hreqmsg for calls that don't otherwise need one, and the httpresponsemessage doesn't really work with the idea of writing output directly.

There were also concerns they had beyond perf with that idea... One would be if you took an arbitrary message handler and put it in an owin pipeline you couldn't guarantee there would be no quirks, bugs, or differences that pop up... The other is that it could cause confusion - there is an existing Web API pipeline for message handlers - adding them at a different layer being a redundant and less recommended way of doing the same thing.

Sent from my Windows Phone

From: Ryan Riley
Sent: 3/7/2013 4:50 AM
To: .NET HTTP Abstractions
Subject: Middleware

Reply all
Reply to author
Forward
0 new messages