0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Supported status code as function

refs #9866
This commit is contained in:
kirrg001 2018-10-12 19:44:01 +02:00 committed by Katharina Irrgang
parent 850e3139ee
commit 8b54cfea81

View file

@ -34,7 +34,14 @@ const http = (apiImpl) => {
return result(req, res, next);
}
res.status(apiImpl.statusCode || 200);
let statusCode = 200;
if (typeof apiImpl.statusCode === 'function') {
statusCode = apiImpl.statusCode(result);
} else if (apiImpl.statusCode) {
statusCode = apiImpl.statusCode;
}
res.status(statusCode);
// CASE: generate headers based on the api ctrl configuration
res.set(shared.headers.get(result, apiImpl.headers));