DotNetHypermedia / DotNetHypermedia

Hal media type server side library for .NET
MIT License
14 stars 6 forks source link

Framework interoperability #3

Open JakeGinnivan opened 9 years ago

JakeGinnivan commented 9 years ago

We want to have adapters from this project to NancyFx, WebApi and maybe servicestack.

How do we intergrate. What do each of their media formatters look like, and how can we be compatible and create adapters for all of them.

beyond-code-github commented 9 years ago

What advantage would this bring over say implementing this as middleware?

My thoughts are that the middleware approach bypasses these interop issues nicely... For example no need to implement conneg or media formatting as those are not invariants with HAL. Most frameworks are going to be sitting on top of OWIN going forward anyways...

JakeGinnivan commented 9 years ago

If middleware is the best way to integrate sure.

The primary goal of this project is to specify hypermedia and serialise it with hypermedia.

This is an open question that needs to be answered before we start coding otherwise we might hit a wall

wis3guy commented 9 years ago

@Roysvork Could you elaborate on your statement? This might be my lack of experience with OWIN, but i fail to see how we would be able to implement this as middleware? Would we then not be circumventing existing features of these frameworks (like MediaTypeFormatters in WebApi)? Again, i'm no expert on OWIN (reading up right now)!

The way you describe it, we should be able to create generic implementations for any format we choose to support across many frameworks as long as they are built on top of OWIN middleware ... which sounds very appealing! ;-)

glennblock commented 9 years ago

I agree with @Roysvork. OWIN is where things are heading (including Web API). In that world, middleware is the right abstraction for handling this in an agnostic fashion.

In my mental model for hypermedia, there are 2 major layers, there's the upper level components in the app that populate some sort of model which has hypermedia in it. Then there are the lower level components that take that model and write it out to the wire. That lower level can absolutely be middleware, which both Nancy and Web API support.

glennblock commented 9 years ago

The upper level will likely have to take some framework dependencies / adapters, though a lot of that depends on how it is implemented. For example OWIN has a request, but Nancy has its own context object. When I am working at the higher levels I will probably need to access these. This came out when @jchannon tried to port my CJ friends example to work on Nancy. Depending on how the abstractions are implement this may or may not impact the design.

glennblock commented 9 years ago

As an example of how this plays out with my CJ library. At the upper level there are collection document readers and writers. The writer will take an object that it is given and product a CJ specific object model. That model will then get passed down through Web API to a formatter which picks it up and writes it back to the response stream.

The same model could equally work with replacing the formatter as a piece of middleware.