2014-06-05 00:42:18 +00:00
|
|
|
/*!
|
2013-11-18 14:36:13 +00:00
|
|
|
* Export the middleware.
|
2014-06-05 00:42:18 +00:00
|
|
|
* See discussion in Connect pull request #954 for more details
|
|
|
|
* https://github.com/senchalabs/connect/pull/954.
|
2013-11-18 14:36:13 +00:00
|
|
|
*/
|
|
|
|
module.exports = urlNotFound;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert any request not handled so far to a 404 error
|
|
|
|
* to be handled by error-handling middleware.
|
2014-06-05 00:42:18 +00:00
|
|
|
* @header loopback.urlNotFound()
|
2013-11-18 14:36:13 +00:00
|
|
|
*/
|
|
|
|
function urlNotFound() {
|
|
|
|
return function raiseUrlNotFoundError(req, res, next) {
|
|
|
|
var error = new Error('Cannot ' + req.method + ' ' + req.url);
|
|
|
|
error.status = 404;
|
|
|
|
next(error);
|
|
|
|
}
|
|
|
|
}
|