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

Function createServer

test/json.js:715–733  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

713})
714
715function createServer (opts) {
716 var _bodyParser = typeof opts !== 'function'
717 ? bodyParser.json(opts)
718 : opts
719
720 return http.createServer(function (req, res) {
721 _bodyParser(req, res, function (err) {
722 if (err) {
723 res.statusCode = err.status || 500
724 res.end(req.headers['x-error-property']
725 ? err[req.headers['x-error-property']]
726 : ('[' + err.type + '] ' + err.message))
727 } else {
728 res.statusCode = 200
729 res.end(JSON.stringify(req.body))
730 }
731 })
732 })
733}
734
735function parseError (str) {
736 try {

Callers 1

json.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected