[WebSocketServer] Allow to use a custom IncomingMessage class#2122
[WebSocketServer] Allow to use a custom IncomingMessage class#2122vansergen wants to merge 3 commits intowebsockets:masterfrom vansergen:request
IncomingMessage class#2122Conversation
|
This is already supported via the const http = require('http');
const { WebSocketServer } = require('ws');
class MyIncomingMessage extends http.IncomingMessage {}
const server = http.createServer({ IncomingMessage: MyIncomingMessage });
const wss = new WebSocketServer({ server });
wss.on('connection', function (ws, request) {
console.log(request instanceof MyIncomingMessage); // true
});
server.listen(8080); |
|
The |
Actually, that is the reason why I created this PR - to simplify this (when the
Totally agree. One could have more flexibility with
is exactly what is needed (426 responses by default). @lpinca I know you do not like adding extra options, but this one seems natural to me. We can use an extended |
A custom |
Agree, but we use things |
|
I mean events like |
|
This opens the doors to every other option listed here https://nodejs.org/api/http.html#httpcreateserveroptions-requestlistener and here https://nodejs.org/api/https.html#httpscreateserveroptions-requestlistener. I don't want that when the What are the benefits of supporting this option? A total of ~10 lines of boilerplate code removed? Sorry but the cons outweigh the pros. |
I disagree. The server itself(when the |
It does not matter. If the Again, the |
|
I'm closing this. Thank you anyway. |
Motivation