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

feat: Add query params to websocket requests #485

Merged
merged 3 commits into from
Jul 12, 2023
Merged

Conversation

tjholm
Copy link
Member

@tjholm tjholm commented Jul 12, 2023

To allow interaction with normal HTTP requests we require that additional information can be provided during the upgrade process of a websocket connection.

A common way to facilitate this is by using query paramaters.

Use Case:

Priming state/pre-authorizing sessions:

Suppose we wanted to create an app like firepoker. You could facilitate this entirely over websockets, however it would be more efficient/cost-effective to manage this using a HTTP API instead.

Step 1: Create a new session using an API

POST /api/session

this would provide a token and connection URL for joining the newly created session.

Step 2: Connect to the new session using websockets

Using the token provided in the previous request we will now be able to join the session

new WebSocket("wss://my-websocket-address.com?session=abcd1234")

During connection this information could be used to isolate communcation between websockets that share a session as part of connection storage/management.

This essentially allows for multi-session websocket applications.

@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

Patch coverage: 37.50% and project coverage change: -0.06 ⚠️

Comparison is base (f8ccb10) 56.08% compared to head (325d5d0) 56.02%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #485      +/-   ##
===========================================
- Coverage    56.08%   56.02%   -0.06%     
===========================================
  Files           50       50              
  Lines         4880     4887       +7     
===========================================
+ Hits          2737     2738       +1     
- Misses        1944     1948       +4     
- Partials       199      201       +2     
Flag Coverage Δ
aws 55.64% <37.50%> (-0.23%) ⬇️
azure 60.80% <ø> (ø)
core 61.22% <ø> (ø)
gcp 42.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cloud/aws/runtime/gateway/lambda.go 52.95% <37.50%> (-0.87%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tjholm tjholm merged commit 2cb1307 into develop Jul 12, 2023
@tjholm tjholm deleted the ws-query-params branch July 12, 2023 01:32
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.

3 participants