Add access to Request or headers in onUpgrade
closure on client-side
#151
Labels
enhancement
New feature or request
onUpgrade
closure on client-side
#151
Is your feature request related to a problem? Please describe.
I'm using WebSocketKit on both the Vapor server-side, and from a client-side. For my own custom authentication system, I'd like to send something in the initial request headers from the client (already possible), then do some stuff with it to generate an authentication token on the server-side (already possible, server-side
shouldUpgrade
closure), and then send the token back in the response headers (already possible, server-sideshouldUpgrade
closure). The problem is the client being able to receive that. As of now, WebSocketKit doesn't give the client-side connecting functions access to theRequest
or headers in the upgradingRequest
from the server.I found where it's accessed in the package code, but it's not made accessible to the client:
websocket-kit/Sources/WebSocketKit/WebSocketClient.swift
Lines 137 to 143 in 4232d34
I even did a test of my workflow and put a breakpoint there to inspect
req
, and it had the header I was looking for.Describe the solution you'd like
Is it possible to add a
req
orheaders
parameter to theonUpgrade closure? Or a way to access it from the
WebSocket` instance, like a new property on it?Describe alternatives you've considered
Alternatively, I can set up my workflow to be sent via standard message as soon as the connection is upgraded (which is probably what I'll do until this is resolved), but I love for this to be integrated into the connection setup.
Thanks in advance for any help with this!
The text was updated successfully, but these errors were encountered: