Skip to content

Commit

Permalink
Add example of catch-all handler with extension handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cleishm committed Dec 11, 2011
1 parent c16fc9d commit a2cc10a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,20 @@ app.get('/index.:format?', function(req, res, next) {
});
```

Picking up the filename extension on a "catch-all" route is a little trickier.
The following example uses a regex to achieve this:

## License
```javascript
app.get(/^.*?(?:\.([^\.\/]+))?$/, function(req, res) {
req.negotiate(req.params[0], {
'application/json': function() {
res.send('{ message: "Hello World" }');
}
});
});
```

## License

(The MIT License)

Expand Down

0 comments on commit a2cc10a

Please sign in to comment.