mikeal/tako — Issue #2: Feedback
Author: DTrejo
Created: 2012-03-06 20:07:00+00:00
State: open

Hey Mikeal,
Some things that happened when I tried to use tako for my static site:

```js
PUBLIC = path.join(__dirname, 'public')
app.route('/').files(PUBLIC)
```

- sub-folders of `/public` are not correctly found & served by filed
- if the file is not found, there is not a good way to serve a 404 page, e.g. public/404.html (I took a stab at writing this, but it doesn't feel very elegant)

```js
app.notfound.html = path.join(PUBLIC, '404.html');
```

And in app.notfound:

```diff
@@ -437,10 +437,16 @@ Application.prototype.notfound = function (req, resp) {
resp.setHeader('content-type', cc)
if (cc === 'text/html') {
body = '

Not Found

'
+ if (this.notfound.html) return filed(this.notfound.html).pipe(resp)
} else if (cc === 'application/json') {
body = JSON.stringify({status:404, reason:'not found', message:'not found'})
} else {
body = 'Not Found'
+ if (this.notfound.html) {
+ resp.setHeader('content-type', 'text/html')
+ console.log('fugg', this.notfound.html, resp.getHeader('content-type'))
+ return filed(this.notfound.html).pipe(resp);
+ }
}
resp.end(body)
}
```