mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 20:55:30 +02:00
Better notFoundGenerator
This commit is contained in:
parent
69ced917f3
commit
0b77c1f79e
1 changed files with 7 additions and 8 deletions
|
@ -131,18 +131,17 @@ exports.getModule = class GopherModule extends ServerModule {
|
|||
}
|
||||
|
||||
routeRequest(selector, socket) {
|
||||
let generator;
|
||||
let match;
|
||||
for(let [regex, gen] of this.routes) {
|
||||
match = selector.match(regex);
|
||||
if(match) {
|
||||
generator = gen;
|
||||
break;
|
||||
return gen(match, res => {
|
||||
return socket.end(`${res}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
generator = generator || this.notFoundGenerator.bind(this);
|
||||
generator(match, res => {
|
||||
socket.end(`${res}`);
|
||||
this.notFoundGenerator(selector, res => {
|
||||
return socket.end(`${res}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -169,8 +168,8 @@ exports.getModule = class GopherModule extends ServerModule {
|
|||
});
|
||||
}
|
||||
|
||||
notFoundGenerator(selectorMatch, cb) {
|
||||
this.log.trace( { selector : selectorMatch[0] }, 'Serving not found content');
|
||||
notFoundGenerator(selector, cb) {
|
||||
this.log.trace( { selector }, 'Serving not found content');
|
||||
return cb('Not found');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue