forked from thoughtpalette/SailsJS_SinglePageAPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path404.js
More file actions
31 lines (26 loc) · 714 Bytes
/
404.js
File metadata and controls
31 lines (26 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Default 404 (not found) handler
*
* If no matches are found, Sails will respond using this handler:
*
* For more information on 404/notfound handling in Sails/Express, check out:
* http://expressjs.com/faq.html#404-handling
*/
module.exports[404] = function pageNotFound(req, res, express404Handler) {
var statusCode = 404;
var result = {
status: statusCode
};
// If the user-agent wants a JSON response, send json
if (req.wantsJSON) {
return res.json(result, result.statusCode);
}
// Otherwise, serve the `views/404.*` page
var view = '404';
res.render(view, result, function (err) {
if (err) {
return express404Handler();
}
res.render(view);
});
};