node.js - Difficulty understanding nodejs documentation -
i'm confused section
http://nodejs.org/api/http.html#http_http_createserver_requestlistener
the requestlistener function automatically added 'request' event.
what term "added" mean?
also here http://nodejs.org/api/http.html#http_event_request
what the code directly beneath mean function (request, response) { }
? mean that function gets passed each time there request?
if statement
var app = http.createserver( function reqlistener(request, response){...} ).listen(1337);
where function reqlistener
requestlistener argument, equivalent following
var app = http.createserver().listen(1337); app.on('request', function reqlistener(request, response){...} );
so shortcut providing listener event request
during server start itself. event request
emitted each request once when received server.
Comments
Post a Comment