Permalink
Browse files

updated examples

  • Loading branch information...
1 parent 08de183 commit 4c6bdbd94f7392894d27217451c922684a363a3a @Raynos committed Jul 15, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 README.md
View
@@ -18,15 +18,15 @@ anyBody will detect the content-type of the request and use the appropiate body
http.createServer(function (req, res) {
if (req.url === '/json') {
- jsonBody(req, function (body) {
+ jsonBody(req, res, function (body) {
res.end(JSON.stringify(body))
})
} else if (req.url === '/form') {
- formbody(req, function (body) {
+ formbody(req, res, function (body) {
res.end(JSON.stringify(body))
})
} else if (req.url === '/any') {
- anyBody(req, function (body) {
+ anyBody(req, res, function (body) {
res.end(JSON.stringify(body))
})
} else {
@@ -38,17 +38,17 @@ anyBody will detect the content-type of the request and use the appropiate body
## Example with custom error handling
- var body = require("routil-body")({
+ var jsonBody = require("routil-body")({
errorPage: function (req, res, errorData) {
// errorData is either a single value or an array of values
// the values are either a number for the HTTP response code
// or an object error object
}
- }).body
+ }).jsonBody
, http = require('http')
http.createServer(function (req, res) {
- body(req, function (body) { res.end(body) })
+ jsonBody(req, function (body) { res.end(body) })
}).listen(8080)
## Installation

0 comments on commit 4c6bdbd

Please sign in to comment.