/**
 * notFound.js
 *
 * A custom response that content-negotiates the current request to either:
 *  * Log out the current user and redirect them to the login page
 *  * Or send back 404 (Not Found) with no response body.
 *
 * Example usage:
 * ```
 * return res.notFound();
 * ```
 */

module.exports = function notFound(data) {

    // Get access to `req` and `res`
    var req = this.req;
    var res = this.res;

    // If no data was provided, respond with 404 Not Found and no body.
    if (data === undefined) {
        return res.status(404).send();
    }

    // If the request wants JSON, send back the data with a 404 status code.
    if (req.wantsJSON) {
        return res.status(404).json(data);
    }

    // If the request wants HTML, send back the data with a 404 status code.
    return res.status(404).send(data);
};
