mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-06-01 03:20:48 +08:00
added index support for file collections
This commit is contained in:
@@ -68,8 +68,6 @@ var router = module.exports = function (req, res, next) {
|
||||
};
|
||||
return next();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// first look for a resource at the given path
|
||||
// eg. `/todos` or `/my-files`
|
||||
|
||||
@@ -28,7 +28,25 @@ module.exports = function (req, res, next, use) {
|
||||
|
||||
// list files
|
||||
if(!filename) {
|
||||
req.directory = true;
|
||||
// return index.html if it exists
|
||||
req.query._id = 'index.html';
|
||||
storage.exec(req, function (err, body) {
|
||||
if(!req.isRoot && body && body.file) {
|
||||
res.header('Content-Type', mimeType);
|
||||
res.header('Transfer-Encoding', 'chunked');
|
||||
body.file.stream(true).pipe(res);
|
||||
} else {
|
||||
// just display the directory
|
||||
delete req.query._id;
|
||||
req.directory = true;
|
||||
storage.exec(req, function (err, body) {
|
||||
res.data = body;
|
||||
next(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// require a content type
|
||||
|
||||
Reference in New Issue
Block a user