Skip to content

Conversation

@mordhaus
Copy link

@mordhaus mordhaus commented Oct 28, 2025

This pull request refactors how the websocket subprotocol is handled.

Previously, the code iterated through the Sec-WebSocket-Protocol
header to find a supported protocol. This change removes that manual
iteration and relies on the websocket upgrader (e.g.,
gorilla/websocket) to correctly negotiate and select the subprotocol
from the list provided by the client.

The handler logic has been moved into a dispatcher, which makes it
easier to extend the codebase with support for additional subprotocols
in the future, such as the newer graphql-transport-ws protocol (as
mentioned in issue #38).

Changes:

  • Removed the manual for loop that iterated over websocket
    subprotocols.
  • Delegated subprotocol detection to the websocket upgrader.
  • Introduced a dispatcher to route connections based on the negotiated
    subprotocol.
  • This change is foundational for adding support for the
    graphql-transport-ws subprotocol.

@mordhaus mordhaus force-pushed the feature/add-ws-subprotocol-dispatcher branch 2 times, most recently from f0e6b55 to 84d5df6 Compare October 28, 2025 22:55
This pull request refactors how the websocket subprotocol is handled.

Previously, the code iterated through the Sec-WebSocket-Protocol
header to find a supported protocol. This change removes that manual
iteration and relies on the websocket upgrader (e.g.,
gorilla/websocket) to correctly negotiate and select the subprotocol
from the list provided by the client.

The handler logic has been moved into a dispatcher, which makes it
easier to extend the codebase with support for additional subprotocols
in the future, such as the newer graphql-transport-ws protocol (as
mentioned in issue graph-gophers#38).

Changes:
- Removed the manual for loop that iterated over websocket
subprotocols.
- Delegated subprotocol detection to the websocket upgrader.
- Introduced a dispatcher to route connections based on the negotiated
subprotocol.
- This change is foundational for adding support for the
graphql-transport-ws subprotocol.
@mordhaus mordhaus force-pushed the feature/add-ws-subprotocol-dispatcher branch from 84d5df6 to 0747574 Compare October 28, 2025 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant