When composing your server apps with OWIN there are many options. OWIN spec is very flexible and it doesn’t force you into particular application architecture (this is a good thing). So, using standard OWIN middleware components to compose your application is pretty easy and straightforward.
I prefer to clearly (at the assembly level) separate middleware from the server and the application. That makes it easier to work with for a bigger team, and when potentially, application teams are not the same as server and/or middleware team. Organizing your application in this way could look something like this, starting with middleware components project:
and then application is configured and ran like this:
So, having this in place, application developers – potentially different team(s) then middleware team – would write:
which models application interface as resources, and exposes them via standard HTTP verbs…
If you prefer CQRS – you can have middleware dispatch to handlers and then write your applications something like this:
Bottom line, OWIN is awesome.