mirror of https://gitee.com/bigwinds/arangodb
Validate request headers also
This commit is contained in:
parent
4466925398
commit
0867e8aa87
|
@ -209,6 +209,7 @@ function applyPathParams(route) {
|
|||
function dispatch(route, req, res) {
|
||||
let pathParams = {};
|
||||
let queryParams = Object.assign({}, req.queryParams);
|
||||
let headers = Object.assign({}, req.headers);
|
||||
|
||||
{
|
||||
let basePath = [];
|
||||
|
@ -283,8 +284,24 @@ function dispatch(route, req, res) {
|
|||
}
|
||||
}
|
||||
|
||||
if (context._headers.size) {
|
||||
try {
|
||||
item.headers = validation.validateParams(
|
||||
context._headers,
|
||||
req.headers,
|
||||
'header'
|
||||
);
|
||||
} catch (e) {
|
||||
throw Object.assign(
|
||||
new httperr.BadRequest(e.message),
|
||||
{cause: e}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let tempPathParams = req.pathParams;
|
||||
let tempQueryParams = req.queryParams;
|
||||
let tempHeaders = req.headers;
|
||||
let tempSuffix = req.suffix;
|
||||
let tempPath = req.path;
|
||||
let tempReverse = req.reverse;
|
||||
|
@ -353,11 +370,14 @@ function dispatch(route, req, res) {
|
|||
if (item.endpoint || item.router) {
|
||||
pathParams = Object.assign(pathParams, item.pathParams);
|
||||
queryParams = Object.assign(queryParams, item.queryParams);
|
||||
headers = Object.assign(headers, item.headers);
|
||||
req.pathParams = pathParams;
|
||||
req.queryParams = queryParams;
|
||||
req.headers = headers;
|
||||
} else {
|
||||
req.pathParams = Object.assign({}, pathParams, item.pathParams);
|
||||
req.queryParams = Object.assign({}, queryParams, item.queryParams);
|
||||
req.headers = Object.assign({}, headers, item.headers);
|
||||
}
|
||||
|
||||
if (!context._handler) {
|
||||
|
@ -372,6 +392,7 @@ function dispatch(route, req, res) {
|
|||
req.reverse = tempReverse;
|
||||
req.path = tempPath;
|
||||
req.suffix = tempSuffix;
|
||||
req.headers = tempHeaders;
|
||||
req.queryParams = tempQueryParams;
|
||||
req.pathParams = tempPathParams;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue