Absinthe: test whether connection is http or socket?

I want to write a middleware where I test if data received from the subscription is authorized (even though I can subscribe to specific topics/ids/… I just want to add that additional security).

For this I need to know in the Absinthe middleware whether I deal with a WebSocket or an http connection. What is the best way to test this?

For now I write unless match?(%{conn: _}, resolution.context) but this might not be safe, not sure.

Subscriptions are allowed over HTTP, so I don’t think this check will actually allow what you think. You should also never put the conn in the Absinthe context since it can’t safely manipulate the conn. This feels like an XY problem, can you elaborate on the logic you are trying to implement?

1 Like