diff --git a/README.md b/README.md index 610935305..048c7b4fc 100755 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Current version: **0.11.3**
- [**Server Events**](#server-events) - - [**Server Route Not Found](#not-found) + - [**Server Route Not Found**](#server-route-not-found) - [**Route Configuration**](#route-configuration) - [Configuration options](#configuration-options) @@ -55,7 +55,7 @@ Current version: **0.11.3** - [View](#view) - [Docs](#documentation) - [Request Logging](#request-logging) - - [Not Found](#not-found) + - [Not Found](#not-found-handler) - [Query Validation](#query-validation) - [Payload Validation](#payload-validation) - [Path Validation](#path-validation) @@ -462,7 +462,7 @@ The server object emits the following events: - _'tail'_ - emitted when a request finished processing, including any registered tails as described in [Request Tails](#request-tails). -## Not Found +## Server Route Not Found **hapi** provides a default handler for unknown routes (HTTP 404). If the application needs to override the default handler, it can use the `setNotFound` server method. The method takes a route configuration object with a handler property. @@ -1165,7 +1165,7 @@ http.start(); The 'request.log' method is always available. -### Not Found +### Not Found Handler Whenever a route needs to respond with a simple 404 message use the _'notFound'_ handler. This can be done by simply setting the route _'handler'_ property to the string 'notFound'. Below is an example of a route that responds with a 404. ```javascript diff --git a/lib/server.js b/lib/server.js index 39a6dbfef..7c64f8da9 100755 --- a/lib/server.js +++ b/lib/server.js @@ -198,7 +198,7 @@ internals.Server.prototype._dispatch = function (options) { } } - request._execute(self._routes['*']); + request._execute(self._routes.notFound); }); }; }; @@ -238,7 +238,7 @@ internals.Server.prototype._routeTable = function () { Object.keys(this._routes).forEach(function (method) { - if (method !== '*') { + if (method !== 'notFound') { self._routes[method].forEach(function (route) { flattenedRoutes.push(route); @@ -306,7 +306,7 @@ internals.Server.prototype.setNotFound = function (routeConfig) { Utils.assert(routeConfig && routeConfig.handler, 'routeConfig must exist and provide a handler'); - this._routes['*'] = new Route({ method: '*', path: '/{p*}', config: routeConfig }, this); + this._routes.notFound = new Route({ method: 'notFound', path: '/{p*}', config: routeConfig }, this); };