New async run launch option in API: return only a portion of the response

This commit is contained in:
Gaël Métais
2015-01-05 11:45:52 +01:00
parent 249cfa21e3
commit e26fd5ed6f
2 changed files with 49 additions and 2 deletions
+20 -2
View File
@@ -23,7 +23,8 @@ var ApiController = function(app) {
runId: (Date.now()*1000 + Math.round(Math.random()*1000)).toString(36),
params: {
url: req.body.url,
waitForResponse: req.body.waitForResponse !== false
waitForResponse: req.body.waitForResponse !== false,
partialResult: req.body.partialResult || null
}
};
@@ -63,7 +64,24 @@ var ApiController = function(app) {
// Send result if the user was waiting
if (run.params.waitForResponse) {
res.redirect(302, '/api/results/' + run.runId);
// If the user only wants a portion of the result (partialResult option)
switch(run.params.partialResult) {
case 'generalScores':
res.redirect(302, '/api/results/' + run.runId + '/generalScores');
break;
case 'rules':
res.redirect(302, '/api/results/' + run.runId + '/rules');
break;
case 'javascriptExecutionTree':
res.redirect(302, '/api/results/' + run.runId + '/javascriptExecutionTree');
break;
case 'phantomas':
res.redirect(302, '/api/results/' + run.runId + '/toolsResults/phantomas');
break;
default:
res.redirect(302, '/api/results/' + run.runId);
}
}
})