Skip to content

Latest commit

 

History

History
executable file
·
33 lines (29 loc) · 780 Bytes

Express_body-parser.md

File metadata and controls

executable file
·
33 lines (29 loc) · 780 Bytes

Express body-parser 1.19.0

Endpoint

var bodyParser = require('body-parser')
var app = express()
app.use(bodyParser.json())

app.use(function (req, res) {
  data = req.body

Source code (/jshttp/type-is/index.js)

function mimeMatch (expected, actual) {
  ...
  var actualParts = actual.split('/')
  var expectedParts = expected.split('/')
  ...
  if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) {
    return false
  }
  ...
  if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) {
    return false
  }

JSON Content-Type
Strict parsing by default

application/json