athena-framework / athena

An ecosystem of reusable, independent components
https://athenaframework.org
MIT License
211 stars 17 forks source link

Mercure Protocol integration #114

Open AndiLavera opened 3 years ago

AndiLavera commented 3 years ago

Currently Athena::Routing::Response lacks support for websockets. Upon some investigation, HTTP::Server::Response#update_handler needs to be set & Athena::Routing::Response does not currently support that.

Blacksmoke16 commented 2 years ago

So unfortunately after thinking about this for a while, I've come to realize that websockets just do not fit into the overall design of Athena. https://github.com/athena-framework/athena/issues/129 could be used as a pretty decent solution in allowing usage of the stdlib's/external shard's HTTP::Handler websocket implementation without needing any changes to Athena.

The main downside of that is the integration between Athena and your websocket logic would be lacking (no DI/abstractions). Ultimately, I think a https://mercure.rocks/ integration would cover the majority of websocket use cases, while better fitting in with Athena's architecture. Can reference https://symfony.com/doc/current/mercure.html for how that might end up looking.

Going to repurpose this issue to represent that implementation.

Blacksmoke16 commented 9 months ago

Looked into this, and don't actually think it would be all that hard to integrate into the framework. There's still a good amount that needs to be figured out/cleaned up, but I put together a proof of concept: https://github.com/Blacksmoke16/athena-mercure

Overall it's pretty simple, just using normal HTTP stuff. Authentication is a bit more unique, but still mostly just cookies and HTTP stuff via JWTs. The repo could use some more helpers for like auth or discovery, and better way to configure things the way you want. This should be doable via #337 by having a dedicated Athena::Mercure::Bundle that allows configuring things/handling the integration between the framework and a more generic Mercure component.

Deff is something to look into once the config stuff is more ironed out.