Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance code re-usability #208

Open
2 tasks done
bahamut657 opened this issue Jun 16, 2022 · 5 comments
Open
2 tasks done

Enhance code re-usability #208

bahamut657 opened this issue Jun 16, 2022 · 5 comments

Comments

@bahamut657
Copy link

bahamut657 commented Jun 16, 2022

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 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.

@bahamut657 bahamut657 changed the title Make the library logic re-usable Enanche code re-usability Jun 16, 2022
@mcollina
Copy link
Member

In my case I have to add custom headers on HTTP Upgrade response #204 (ws library under the hood, supports it).

I would actually prefer to have a PR that added support for this.

@airhorns
Copy link
Member

^ 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?

@mcollina
Copy link
Member

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.

@bahamut657
Copy link
Author

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.

@mcollina
Copy link
Member

mcollina commented Jul 8, 2022

I would actually prefer a PR that adds support for whatever use case you think it's missing rather than exposing internals.

@Uzlopak Uzlopak changed the title Enanche code re-usability Enhance code re-usability Nov 30, 2022
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

No branches or pull requests

3 participants