router index signature changed
This commit is contained in:
1 parent
872d686a1b
commit
ac99501dad
1 file changed
+11
-2
+11
-2
@@ -40,8 +40,17 @@ export function accepts(routes, def) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function index(filename = config['defaultIndex']) {
|
export function index(fn) {
|
||||||
|
let filename = config['defaultIndex'];
|
||||||
|
|
||||||
return function *() {
|
return function *() {
|
||||||
|
let test = true;
|
||||||
|
if(fn) test = yield fn();
|
||||||
|
|
||||||
|
if(!test) {
|
||||||
|
this.status = 404;
|
||||||
|
}
|
||||||
|
|
||||||
this.type = 'text/html';
|
this.type = 'text/html';
|
||||||
this.body = fs.createReadStream(filename);
|
this.body = fs.createReadStream(filename);
|
||||||
}
|
}
|
||||||
@@ -51,4 +60,4 @@ export const json = fn => accepts({
|
|||||||
'text/html': index(),
|
'text/html': index(),
|
||||||
'text/plain': index(),
|
'text/plain': index(),
|
||||||
'application/json': fn
|
'application/json': fn
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user