MCPcopy
hub / github.com/scality/cloudserver / healthcheckHandler

Function healthcheckHandler

lib/utilities/healthcheckHandler.js:125–144  ·  view source on GitHub ↗

* Checks if client IP address is allowed to make http request to * S3 server. Defines function 'healthcheckEndHandler', which is * called if IP not allowed or passed as callback. * @param {object} clientIP - IP address of client * @param {object} req - http request object * @param {object} res

(clientIP, req, res, log, statsClient, deep)

Source from the content-addressed store, hash-verified

123 * @return {undefined}
124 */
125function healthcheckHandler(clientIP, req, res, log, statsClient, deep) {
126 function healthcheckEndHandler(err, results) {
127 writeResponse(res, err, log, results, error => {
128 if (error) {
129 return log.end().warn('healthcheck error', { err: error });
130 }
131 return log.end();
132 });
133 }
134
135 // Attach the apiMethod method to the request, so it can used by monitoring in the server
136 // eslint-disable-next-line no-param-reassign
137 req.apiMethod = deep ? 'deepHealthcheck' : 'healthcheck';
138
139 if (!checkIP(clientIP)) {
140 return healthcheckEndHandler(errors.AccessDenied, []);
141 }
142 return routeHandler(deep, req, res, log, statsClient,
143 healthcheckEndHandler);
144}
145
146module.exports = {
147 isHealthy,

Callers 2

routeAdminRequestMethod · 0.85

Calls 3

checkIPFunction · 0.85
healthcheckEndHandlerFunction · 0.85
routeHandlerFunction · 0.70

Tested by

no test coverage detected