(opts)
| 571 | }) |
| 572 | |
| 573 | function createServer (opts) { |
| 574 | const _bodyParser = typeof opts !== 'function' |
| 575 | ? bodyParser.text(opts) |
| 576 | : opts |
| 577 | |
| 578 | return http.createServer(function (req, res) { |
| 579 | _bodyParser(req, res, function (err) { |
| 580 | res.statusCode = err ? (err.status || 500) : 200 |
| 581 | res.end(err |
| 582 | ? ('[' + err.type + '] ' + err.message) |
| 583 | : (JSON.stringify(req.body) || typeof req.body) |
| 584 | ) |
| 585 | }) |
| 586 | }) |
| 587 | } |