Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] upgrade hapi #571

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
upgrade handlers
  • Loading branch information
AlvaroVega committed Dec 21, 2021
commit 80d5d6b2f627a1ebfc47843948a3d1cefbd2e03e
1 change: 1 addition & 0 deletions lib/server/handlers/sthGetLogLevelHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function getLogLevelHandler(request, reply) {

const response = reply(getLogLevelResponse(level));
sthServerUtils.addFiwareCorrelator(request, response);
return response;
}

module.exports = getLogLevelHandler;
2 changes: 1 addition & 1 deletion lib/server/handlers/sthGetVersionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const sthUtils = require(ROOT_PATH + '/lib/utils/sthUtils');
*/
function getVersionHandler(request, reply) {
const message = sthUtils.getVersion();
return reply(message);
return reply.response(message);
}

module.exports = getVersionHandler;
5 changes: 3 additions & 2 deletions lib/server/handlers/sthNotFoundHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ function notFoundHandler(request, reply) {
'404 - Not Found route for the request: ' + request.method.toUpperCase() + ' ' + request.url.path
);
if (request.path.startsWith('/STH/v2')) {
response = reply({ error: 'NotFound', description: 'invalid path' }).code(404);
response = reply.response({ error: 'NotFound', description: 'invalid path' }).code(404);
} else {
response = reply({ statusCode: 404, error: 'Not Found' }).code(404);
response = reply.response({ statusCode: 404, error: 'Not Found' }).code(404);
}
sthServerUtils.addFiwareCorrelator(request, response);
return response;
}

module.exports = notFoundHandler;
8 changes: 4 additions & 4 deletions lib/server/handlers/sthNotificationHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function storeRawData(data, reply, callback) {
sthLogger.debug(request.sth.context, 'Raw data successfully stored');
}
if (++counterObj.counter === totalTasks) {
response = reply(err);
response = reply.response(err);
sthServerUtils.addFiwareCorrelator(request, response);
}
process.nextTick(callback.bind(null, err));
Expand Down Expand Up @@ -255,7 +255,7 @@ function storeAggregatedData(data, reply) {
// There was an error when getting the collection
sthLogger.error(request.sth.context, 'Error when getting the aggregated data collection for storing');
if (++counterObj.counter === totalTasks) {
response = reply(err);
response = reply.response(err);
sthServerUtils.addFiwareCorrelator(request, response);
}
} else {
Expand All @@ -282,7 +282,7 @@ function storeAggregatedData(data, reply) {
sthLogger.debug(request.sth.context, 'Aggregated data successfully stored');
}
if (++counterObj.counter === totalTasks) {
response = reply(err);
response = reply.response(err);
sthServerUtils.addFiwareCorrelator(request, response);
}
}
Expand Down Expand Up @@ -390,7 +390,7 @@ function processNotification(recvTime, request, reply) {
);
const error = boom.badRequest(message);
error.output.payload.validation = { source: 'payload', keys: ['attributes'] };
return reply(error);
return reply.response(error);
}

for (let i = 0; i < contextResponses.length; i++) {
Expand Down
3 changes: 2 additions & 1 deletion lib/server/handlers/sthSetLogLevelHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ function setLogLevelHandler(request, reply) {

sthLogger.info(request.sth.context, 'Log level set to: ' + level);

const response = reply();
const response = reply.response();
sthServerUtils.addFiwareCorrelator(request, response);
return response;
}

module.exports = setLogLevelHandler;