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

[Feature Request: zio-http] Allow customization of WebsocketConfig based on ServerRequests #3290

Closed
kyri-petrou opened this issue Oct 31, 2023 · 1 comment

Comments

@kyri-petrou
Copy link
Contributor

kyri-petrou commented Oct 31, 2023

Following up on this comment.

As mentioned in the comment, zio-http 3.0.0-RC3 added back the ability to provide a custom websocket config when handling a request.

It would be great if we could expose an option (perhaps in ZioHttpServerOptions?) to allow customizing zio-http's WebsocketConfig prior to constructing the response. This would allow us to modify the subprotocols in the config depending on some request params, e.g., headers.

In the case of Caliban, that would be defining the subprotocols based on the sec-websocket-protocol header. We currently have a workaround where we provide a default config that users need to use when initializing the server, but if users skip that step then their GraphQL Subscriptions won't work. This unfortunately degrades UX and could break deployments in production if the WS endpoints are not individually tested at the HTTP layer if the custom config is removed.

I'm happy to submit a PR and add that option in ZioHttpServerOptions, although I thought to open an issue first in case you think there's a better approach to resolving this

@adamw
Copy link
Member

adamw commented Oct 31, 2023

Thanks! If you could prepare a PR, that would be awesome :)

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

2 participants