function healthcheckHandler(clientIP, req, res, log, statsClient) {
    function healthcheckEndHandler(err, results) {
        writeResponse(res, err, log, results, error => {
            if (error) {
                return log.end().warn('healthcheck error', { err: error });
            }
            return log.end();
        });
    }

    const deep = (req.url === '/ready');

    // Attach the apiMethod method to the request, so it can used by monitoring in the server
    // eslint-disable-next-line no-param-reassign
    req.apiMethod = deep ? 'deepHealthcheck' : 'healthcheck';

    if (!checkIP(clientIP)) {
        return healthcheckEndHandler(errors.AccessDenied, []);
    }
    return routeHandler(deep, req, res, log, statsClient,
                        healthcheckEndHandler);
}
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 - http response object
@param {object} log - werelogs logger instance
@param {object} statsClient - StatsClient Instance
@return {undefined}