-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.js
More file actions
executable file
·29 lines (27 loc) · 954 Bytes
/
Copy pathrouter.js
File metadata and controls
executable file
·29 lines (27 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function route(handle, pathname, response, request) {
console.log("About to route a request for " + pathname);
if (typeof handle[pathname] === 'function') {
//return handle[pathname]();
handle[pathname](response, request);
} else {
console.log("No request handler found for " + pathname);
//return "404 Not Found";
response.writeHead(404, {"Content-Type": "text/html"});
response.write("404 Not Found");
response.end();
}
}
// function route(handle, pathname, response, postData) {
// console.log("About to route a request for " + pathname);
// if (typeof handle[pathname] === 'function') {
// //return handle[pathname]();
// handle[pathname](response, postData);
// } else {
// console.log("No request handler found for " + pathname);
// //return "404 Not Found";
// response.writeHead(404, {"Content-Type": "text/plain"});
// response.write("404 Not Found");
// response.end();
// }
// }
exports.route = route;