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

Add req.ws #163

Merged
merged 6 commits into from
Mar 2, 2022
Merged

Add req.ws #163

merged 6 commits into from
Mar 2, 2022

Conversation

a-a-GiTHuB-a-a
Copy link
Contributor

I have added a few lines of code to add a req.ws boolean for if the request was an upgrade for websocket.

@airhorns
Copy link
Member

airhorns commented Nov 29, 2021

Thanks for the PR @a-a-GiTHuB-a-a ! Did you want to work with this one or #162 ?

@a-a-GiTHuB-a-a
Copy link
Contributor Author

Sorry. PR #162 was actually an accident.

@airhorns airhorns mentioned this pull request Nov 30, 2021
4 tasks
index.js Outdated Show resolved Hide resolved
@mcollina
Copy link
Member

Can you please add a unit test? Also CI is failing

BRUH WHY IS IT THROWING ERRORS BECAUSE OF FORMAT
index.js Outdated
@@ -8,7 +8,9 @@ const kWs = Symbol('ws-socket')
const kWsHead = Symbol('ws-head')

function fastifyWebsocket (fastify, opts, next) {
let errorHandler = defaultErrorHandler
fastify.decorateRequest('ws', true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for safety I think it'd make more sense for this to be null by default so that if something changes later with the request hook, it's clear if it has or hasn't been set yet, instead of maybe being a lie (true), you know?

request.ws = false
}
done()
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test so future committers don't break this functionality!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd make sense to add unit tests that check the value of this property is true for a websocket route and false for a non websocket route.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/@a-a-GiTHuB-a-a are you able to copy one of the existing unit tests to get this in?

@mcollina
Copy link
Member

mcollina commented Dec 4, 2021

CI is failing

@a-a-GiTHuB-a-a
Copy link
Contributor Author

I added more patches to the formatting.

index.js Outdated Show resolved Hide resolved
@airhorns
Copy link
Member

@a-a-GiTHuB-a-a did you want to update this PR? it'd be a great feature to get in!

update for PR
@a-a-GiTHuB-a-a
Copy link
Contributor Author

I just did, and it makes sense

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@a-a-GiTHuB-a-a
Copy link
Contributor Author

I removed the trailing spaces. i think.

@mcollina mcollina merged commit 70c8df7 into fastify:master Mar 2, 2022
@airhorns airhorns mentioned this pull request Apr 12, 2022
4 tasks
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