Open bahamut657 opened 2 years ago
In my case I have to add custom headers on HTTP Upgrade response https://github.com/fastify/fastify-websocket/issues/204 (ws library under the hood, supports it).
I would actually prefer to have a PR that added support for this.
^ same, but, we could switch to Symbol.for
instead of Symbol
to allow folks who want to enter the "i know what i am doing and mucking around with the internals" zone to do so, instead of making it impossible?
Using Symbol.for would make them part of the public API anyway. I don't think it's a good idea as we would have to support many more use cases than what we are currently testing.
Ok. Do you think that permitting to override the Symbols in options could be the correct way? (An example here: https://github.com/bahamut657/fastify-websocket/blob/master/index.js)
Let me know and I will make a PR.
I would actually prefer a PR that adds support for whatever use case you think it's missing rather than exposing internals.
Prerequisites
🚀 Feature Proposal
It seems that it could not be possible to manage the upgrade event in custom way, without re-writing the entire logic. The cause seems to be the Symbols used to store headers and socketRef into the
rawReq
object (kWs, kWsHead
)Motivation
Code re-usability. In my case I have to add custom headers on HTTP Upgrade response #204 (
ws
library under the hood, supports it).Example
Replace Symbol usage with simple string keys or expose some properties to manage the key name attribute.