Hi STT,

I'm the author of The Node Beginner Book. I'm not sure which code you are 
referring to. I've searched the book to double-check it, but there is no 
code that looks like

route(handle, pathname, query, response, postData);

At the end of the tutorial, the complete route function signature looks 
like this:

function route(handle, pathname, response, request)

which makes sense because route itself needs handle and pathname, and the 
requestHandlers need at least response, and, in the case of the upload 
handler, also need request.

Regards,
Manuel



On Saturday, March 31, 2012 12:04:55 PM UTC+2, STT wrote:
>
> 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.


On Saturday, March 31, 2012 12:04:55 PM UTC+2, STT wrote:
>
> 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

Reply via email to