Permalink
Browse files

Added usage example

  • Loading branch information...
1 parent 197412c commit 6a140ab90955142d86917a49bff1cc1f15e635af @baryshev committed Aug 11, 2012
Showing with 27 additions and 2 deletions.
  1. +27 −2 README.md
View
@@ -5,6 +5,31 @@ Simple and fast router for Connect
npm install connect-route
-# Example
+# Usage
-See [examples](https://github.com/baryshev/connect-route/tree/master/examples) folder.
+```js
+var
+ connectRoute = require('connect-route');
+ connect = require('connect'),
+ app = connect();
+
+app.use(connectRoute(function (router) {
+ router.get('/', function (req, res, next) {
+ res.end('index');
+ });
+
+ router.get('/home', function (req, res, next) {
+ res.end('home');
+ });
+
+ router.get('/home/:id', function (req, res, next) {
+ res.end('home ' + req.params.id);
+ });
+
+ router.post('/home', function (req, res, next) {
+ res.end('POST to home');
+ });
+}));
+
+server.listen(3000);
+```

0 comments on commit 6a140ab

Please sign in to comment.