router index signature changed

This commit is contained in:
tmshv committed 2016-03-18 01:54:24 +03:00
1 parent 872d686a1b
commit ac99501dad
1 file changed
+10 -1
+10 -1
View File
@@ -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 *() {
let test = true;
if(fn) test = yield fn();
if(!test) {
this.status = 404;
}
this.type = 'text/html';
this.body = fs.createReadStream(filename);
}