mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
53c49b8055
Fixes #17
32 lines
712 B
JavaScript
32 lines
712 B
JavaScript
module.exports = function (logsManager) {
|
|
return {
|
|
index: function(req, res){
|
|
logsManager.logFiles(function (err, files) {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.send(files);
|
|
}
|
|
});
|
|
},
|
|
show: function(req, res){
|
|
var requestedFilename = req.params.log;
|
|
if (req.format) {
|
|
requestedFilename += "." + req.format;
|
|
}
|
|
|
|
logs.getLogFile(requestedFilename, function (err, file) {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
if (file) {
|
|
res.download(file.path);
|
|
} else {
|
|
res.send(404, new Error("File not found"));
|
|
}
|
|
}
|
|
});
|
|
},
|
|
};
|
|
};
|