MCPcopy Create free account
hub / github.com/expressjs/body-parser / createServer

Function createServer

test/raw.js:475–496  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

473})
474
475function createServer (opts) {
476 var _bodyParser = typeof opts !== 'function'
477 ? bodyParser.raw(opts)
478 : opts
479
480 return http.createServer(function (req, res) {
481 _bodyParser(req, res, function (err) {
482 if (err) {
483 res.statusCode = err.status || 500
484 res.end('[' + err.type + '] ' + err.message)
485 return
486 }
487
488 if (Buffer.isBuffer(req.body)) {
489 res.end('buf:' + req.body.toString('hex'))
490 return
491 }
492
493 res.end(JSON.stringify(req.body))
494 })
495 })
496}
497
498function tryRequire (name) {
499 try {

Callers 1

raw.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected