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 custom query params to make-channel-socket! #158

Merged
merged 1 commit into from
Aug 28, 2015

Conversation

danielcompton
Copy link
Collaborator

This patch allows the user to pass additional query parameters in the additional web socket connection. These can be used for authentication. Websockets don't have an API to pass any headers, so any out of band information has to go over the query params.

Because :chsk-url-fn has been deprecated, I think we need to have another parameter for this. A slightly different approach would be to adjust the internal API so client-id isn't passed separately to the map->* functions, but instead we just pass a map of params.

Fixes #135

This patch allows the user to pass additional query parameters in the
additional web socket connection. These can be used for authentication.
Websockets don't have an API to pass any headers, so any out of band
information has to go over the query params.

Fixes #135
@@ -754,7 +754,7 @@

#+cljs ;; Handles reconnects, keep-alives, callbacks:
(defrecord ChWebSocket
[client-id url chs socket_ kalive-ms kalive-timer_ kalive-due?_ nattempt_
[client-id url params chs socket_ kalive-ms kalive-timer_ kalive-due?_ nattempt_
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

client-id and params could be combined.

@ptaoussanis
Copy link
Member

Hi Daniel,

Thanks for the clear PR, much appreciated! 👍

Am I correct in understanding that this change is just to make it easier to include query-params in the chsk URL? You're aware that the URL/path can already contain query params, right?

@ptaoussanis
Copy link
Member

This looks good to me btw, will merge + cut a new release if you give me the go-ahead.

client-id and params could be combined.

Think probably better to keep them separated as you have. They're semantically different (params are user-space, client-id required for the implementation).

@danielcompton
Copy link
Collaborator Author

Am I correct in understanding that this change is just to make it easier to include query-params in the chsk URL? You're aware that the URL/path can already contain query params, right?

Rereading #135 (comment) earlier today when working on this PR I finally clicked on what you were meaning last month. However now that chsk-url-fn has been deprecated I don't see any other way to influence the URL that is used for the connection?

if you give me the go-ahead.

:shipit:

They're semantically different

That's how I felt too.

Thanks!

@ptaoussanis
Copy link
Member

However now that chsk-url-fn has been deprecated I don't see any other way to influence the URL that is used for the connection?

Oh, just with the path argument. So if your path is usually /chsk, you could change it to something like "/chsk/?email=foo%40example.com", etc.

Does that make sense?

Sorry if I wasn't too clear before. In any case, happy with this PR since it definitely makes things easier.

:shipit:

Is that... a gopher? :-)

ptaoussanis added a commit that referenced this pull request Aug 28, 2015
Add custom query params to make-channel-socket!
@ptaoussanis ptaoussanis merged commit 001c4f3 into dev Aug 28, 2015
@ptaoussanis
Copy link
Member

Oh btw see you adjusted this to target the dev branch, thanks!

@danielcompton
Copy link
Collaborator Author

That's the shipit emoji :)

danielcompton added a commit that referenced this pull request Aug 28, 2015
…ompton)

This patch allows the user to pass additional query parameters in the
additional web socket connection. These can be used for authentication.
Websockets don't have an API to pass any headers, so any out of band
information has to go over the query params.

Fixes #135
@ptaoussanis
Copy link
Member

That's the shipit emoji :)

Perhaps telling that I've never seen it before ;-)

Okay, [com.taoensso/sente "1.7.0-alpha4"] is up on Clojars. Does this fully resolve #135 for you? Okay to close that?

@danielcompton
Copy link
Collaborator Author

Yep, closed it now. Thanks!

@danielcompton danielcompton deleted the custom-query-params branch August 28, 2015 05:58
danielcompton added a commit that referenced this pull request Aug 28, 2015
…ompton)

This patch allows the user to pass additional query parameters in the
additional web socket connection. These can be used for authentication.
Websockets don't have an API to pass any headers, so any out of band
information has to go over the query params.

Fixes #135
ptaoussanis added a commit that referenced this pull request Aug 28, 2015
ptaoussanis added a commit that referenced this pull request Aug 28, 2015
@ptaoussanis
Copy link
Member

Quick update: just pushed [com.taoensso/sente "1.7.0-alpha5"] since we missed a case: the params weren't being included in Ajax-based callback requests. Should be okay now.

@danielcompton
Copy link
Collaborator Author

Thanks, and sorry about that.

@ptaoussanis
Copy link
Member

Oh, no problem - easy to miss. PR was very helpful, wouldn't have gotten to this otherwise.

danielcompton added a commit that referenced this pull request Aug 28, 2015
…ompton)

This patch allows the user to pass additional query parameters in the
additional web socket connection. These can be used for authentication.
Websockets don't have an API to pass any headers, so any out of band
information has to go over the query params.

Fixes #135
ptaoussanis added a commit that referenced this pull request Aug 28, 2015
danielcompton added a commit that referenced this pull request Sep 3, 2015
…ompton)

This patch allows the user to pass additional query parameters in the
additional web socket connection. These can be used for authentication.
Websockets don't have an API to pass any headers, so any out of band
information has to go over the query params.

Fixes #135
ptaoussanis added a commit that referenced this pull request Sep 3, 2015
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.

2 participants