Skip to content

Commit

Permalink
[doc] Improve authentication example (#1741)
Browse files Browse the repository at this point in the history
  • Loading branch information
RoTerentev authored Apr 16, 2020
1 parent c31150f commit 6b4e2a8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,10 @@ wss.on('connection', function connection(ws, request, client) {
});

server.on('upgrade', function upgrade(request, socket, head) {
// This function is not defined on purpose. Implement it with your own logic.
authenticate(request, (err, client) => {
if (err || !client) {
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
socket.destroy();
return;
}
Expand Down

0 comments on commit 6b4e2a8

Please sign in to comment.