Hello,
I've just started finding my way around node.js and to do that I have
used this http://www.nodebeginner.org/ tutorial. The author spreads
the different modules - server, router, etc. to different files, and
then uses require to hook them in in the main file.
Now, since they are all hooked in at the begining of the way, I'm
forced to pass arguments into functions, which these particular
functions don't actually need. For example:
route(handle, pathname, query, response, postData);
I pass to the router a list of handles, a pathname, the query attached
to it, the response object and any post data that I have received.
Then the router does this:
handle[pathname](response, query, postData);
Which finally links to this function:
function start(response, query, postData) {
console.log("RH start");
view.readFile("views/page.html","utf8",function (err,data){
if(err){
console.log(err);
return;
}
response.writeHead(200, {"Content-Type:": "text/html"});
response.write(data);
response.end();
});
}
It's just one of the few handlers that I have, but basically what
start actually needed was only the response object. Is this really the
way things are done? Because it seems a bit inefficient to me adding
parameters that aren't actually needed.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en