Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

readme edits

  • Loading branch information...
commit f02dfab97c3fb6038fd3d27ca1608e08eb638637 1 parent c6a710b
@carlos8f authored
Showing with 33 additions and 10 deletions.
  1. +33 −10 README.md
View
43 README.md
@@ -3,23 +3,46 @@ middler
A trivial middleware runner
-Usage
------
+Basic usage
+-----------
```javascript
var middler = require('middler')
- , http = require('http')
+ , server = require('http').createServer()
, buffet = require('buffet')('./public')
-var server = http.createServer();
-middler(server, [
- buffet,
- function(req, res, next) {
+middler(server)
+ .add(buffet)
+ .add(function(req, res, next) {
// ... do some stuff
next();
- },
- buffet.notFound
-]);
+ })
+ .add(buffet.notFound);
+```
+
+Routing
+-------
+
+```javascript
+middler(server)
+ .get('/robots.txt', function (req, res, next) {
+ res.end('humans only!');
+ })
+ .post('/posts/:id', function (req, res, next) {
+ // req.params.id available
+ });
+```
+
+[union](https://github.com/flatiron/union) compatibility
+--------------------------------------------------------
+
+```javascript
+middler(server)
+ .add(function () {
+ // this.req
+ // this.res
+ this.res.emit('next');
+ });
```
License
Please sign in to comment.
Something went wrong with that request. Please try again.