diff --git a/src/routes/index.js b/src/routes/index.js index f0b92d25..b5771013 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -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); } @@ -51,4 +60,4 @@ export const json = fn => accepts({ 'text/html': index(), 'text/plain': index(), 'application/json': fn -}); \ No newline at end of file +});