asset-rack
asset-rack copied to clipboard
StaticAssets should serve index.html at /
It would be nice to have a new option for StaticAssets called something like serveIndex that defaults to true. When true, it would automatically serve index.html when a browser requests /.
In the meantime, here is a workaround:
var rack = require ('asset-rack');
var fs = require('fs');
var assets = new rack.Rack([
new rack.StaticAssets({
urlPrefix: '/',
dirname: __dirname + '/../../splash'
}),
new rack.Asset({
url: '/',
contents: fs.readFileSync(__dirname + '/../../splash/index.html').toString(),
mimetype: 'text/html'
}),
]);
I like this idea, I've been doing something similar.
Although, I'd rather add this feature a little higher up, to the actual rack itself.