Skip to content
Browse files

Updates documentation with information about the `notFound` method.

  • Loading branch information...
1 parent 98bab6f commit 978447a8a07200b3036148c946ac47559dfbb473 @nrstott committed
Showing with 28 additions and 0 deletions.
  1. +28 −0 README.md
View
28 README.md
@@ -86,6 +86,34 @@ router.get('/hello/*', function(req, name) {
});
```
+### No Route Found
+
+When no route pattern matches the request, a `next` jsgi application to be called may
+be specified either with the `router.notFound` method or via a parameter to the function
+returned by `bogart.router`. If both techniques are used, then the parameter overrides
+the app specified by the `router.notFound` method.
+
+```javascript
+// Added via the .notFound method
+var myRouter = bogart.router();
+myRouter.get('/', index);
+myRouter.notFound(function (req) {
+ return bogart.html('Not Found', { status: 404 });
+});
+
+// Specified as a parameter to the router
+var myRouter = bogart.router();
+myRouter.get('/', index);
+
+var app = bogart.app();
+app.use(myRouter(function (req) {
+ return {
+ status: 404,
+ body: [ 'Not Found' ]
+ };
+}))
+```
+
### Regex Routes
When a route pattern is not powerful enough, regular expressions may be used to specify which

0 comments on commit 978447a

Please sign in to comment.
Something went wrong with that request. Please try again.