mirror of https://gitee.com/bigwinds/arangodb
Allow passing strings as status code in some cases
This commit is contained in:
parent
e22e656f5d
commit
30d6200a60
|
@ -194,6 +194,9 @@ module.exports = class SyntheticResponse {
|
|||
}
|
||||
|
||||
sendStatus(status) {
|
||||
if (typeof status === 'string') {
|
||||
status = statuses(status);
|
||||
}
|
||||
const message = String(statuses[status] || status);
|
||||
this.statusCode = status;
|
||||
this.body = message;
|
||||
|
@ -212,6 +215,9 @@ module.exports = class SyntheticResponse {
|
|||
}
|
||||
|
||||
status(statusCode) {
|
||||
if (typeof statusCode === 'string') {
|
||||
statusCode = statuses(statusCode);
|
||||
}
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -262,6 +262,9 @@ module.exports = exports = class SwaggerContext {
|
|||
}
|
||||
|
||||
error(status, reason) {
|
||||
if (typeof status === 'string') {
|
||||
status = statuses(status);
|
||||
}
|
||||
return this.response(
|
||||
status,
|
||||
DEFAULT_ERROR_SCHEMA,
|
||||
|
|
Loading…
Reference in New Issue