Content Negotiation over WebSockets

Did anybody tried to implement websockets content negotiation somehow?

I’m asking it here because I’m thinking to start safe migration (to keep old clients alive) from old plain json websockets document structure to json:api document structure. But understood it’s not that easy.

Even if I will add additional websocket server with json:api events data serialized to json:api structure I will require to send all these events to both of the websocket servers. And there is no possibility to perform content negotiation like via HTTP request, because websocket server connection is stateless and just bypassing all the data it get to people who subscribed to appropriate channel and cannot convert document on the fly. Or am I missing something?

Did you ever tried to use json:api in websockets or it’s not designed for it?

I had a longer reply, but it isn’t worth it. You’ve already seen enough problems. JSONAPI is built for HTTP, and it requires the assumptions made. I wouldn’t use it over websockets for anything other than a normalized serialization format if you wanted to start to support only jsonapi serialization.

1 Like