Open SEAPUNK opened 8 years ago
okay so first, i'll change the handleUpgrade function:
handleUpgrade(req, socket, upgradeHead, listener)
to handleUpgrade(req, socket, upgradeHead, opts)
and create a private fn for listeners only:
_handleListenerUpgrade(req, socket, upgradeHead, listener)
and the handleUpgrade will be an options object with some defaults and will contain things like custom validators
this will change the flow like so:
_handleListenerUpgrade()
will call handleUpgrade()
with its own options object
this way,with custom functions, there is no need to worry about limitations or bikeshedding with things like middleware, because it can be layered on top of each other
good stuff
so, i am halfway done with the server handshaking part of the server, but now i have a couple of things to think about and then implement:
first off, handshake acceptance. while i want validation to follow the RFC, i also want to allow people to change how those parts are handled.
currently, there is
WSServer.handleUpgrade()
, which is a call-and-forget function that handles connection upgrades. all listeners' upgrade handlers call this function, optionally providing themselves for some additional handling.these are the things that are being checked/processed:
[cont.]