Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js make request and response global for HTTP server?

I've just started on node.js and ran through http://nodebeginner.org/index.html. Great start tutorial but I really want to know is it possible to make both request and response 'global' so any module loaded for the current incoming request can access these... rather than injecting.

Ideas?

like image 490
adamwtiko Avatar asked Aug 31 '11 20:08

adamwtiko


1 Answers

Unlike most web-scripting language, in Node many HTTP requests from different clients can be 'active' at the same time. How would you ever know which client you're responding to?

So while you think there's only 1 request and response at any given time, there are actually open requests for all current clients.

like image 107
Evert Avatar answered Nov 10 '22 00:11

Evert