I have encountered with this nice tutorial to node.js.
There is some example there :
var server = require("./server");
var router = require("./router");
var requestHandlers = require("./requestHandlers");
var handle = {}
handle["/"] = requestHandlers.start;
handle["/start"] = requestHandlers.start;
handle["/upload"] = requestHandlers.upload;
server.start(router.route, handle);
Why do I need handle["/"] what is it good for?
he says there :
As you can see, it’s really simple to map different URLs to the same request handler: by adding a key/value pair of "/" and requestHandlers.start, we can express in a nice and clean way that not only requests to /start, but also requests to / shall be handled by the start handler.
why that solve any problem and what is the problem at all?
The function binded to handle[“/”] will be called when somebody visits yoursite.com, and handle[“/start”] will be called for visits to yoursite.com/start
The author is trying to build a server that will display different things based on routes (urls).