vn-cc-vmp/router.js

13 lines
441 B
JavaScript

function route(handle, pathname, response, postData) {
console.log("A punto de rutear una peticion para " + pathname);
if (typeof handle[pathname] === 'function') {
handle[pathname](response, postData);
} else {
console.log("No se ha encontrado manipulador para " + pathname);
response.writeHead(404, {"Content-Type": "text/html"});
response.write("404 No encontrado");
response.end();
}
}
exports.route = route;