http.ServerRequest.prototype
I want to add my own method to htt开发者_开发知识库p.ServerRequest object. But http.ServerRequest is null. I tried requset.prototype.testtest = function() { console.log('aaaaa'); };
in server callback. It answers 'TypeError: Cannot set property 'testtest' of undefined'. How to add method to ServerRequest objects?
You can use http.IncomingMessage.prototype.testtest = function() { ... }
ServerRequest is a IncomingMessage object
精彩评论