From 30d6200a6068b2e9f46919df4080f9d6188a4a68 Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Wed, 13 Apr 2016 15:23:11 +0200 Subject: [PATCH] Allow passing strings as status code in some cases --- js/server/modules/@arangodb/foxx/router/response.js | 6 ++++++ js/server/modules/@arangodb/foxx/router/swagger-context.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/js/server/modules/@arangodb/foxx/router/response.js b/js/server/modules/@arangodb/foxx/router/response.js index ee1127912e..48f0d42500 100644 --- a/js/server/modules/@arangodb/foxx/router/response.js +++ b/js/server/modules/@arangodb/foxx/router/response.js @@ -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; } diff --git a/js/server/modules/@arangodb/foxx/router/swagger-context.js b/js/server/modules/@arangodb/foxx/router/swagger-context.js index 5b82aa4ef1..508c2ce25a 100644 --- a/js/server/modules/@arangodb/foxx/router/swagger-context.js +++ b/js/server/modules/@arangodb/foxx/router/swagger-context.js @@ -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,