Skip to content

Commit

Permalink
Updates documentation with information about the notFound method.
Browse files Browse the repository at this point in the history
  • Loading branch information
nrstott committed Sep 16, 2013
1 parent 98bab6f commit 978447a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 978447a

Please sign in to comment.