zazuko/kopflos

Implicitly fail requests with missing body when operation expects a payload

Opened this issue · 0 comments

It seems repetitive and unnecessary to check the request object every time for the body like

function (req, res) {
  if (!req.dataset) {
    res.send(400)
  }

  // happy path
}

For RDF requests I expect that the operation would be defined as hydra:expects api:SomeClass. I propose to add an implicit check and send a 400 response if the request has no body.

Gotta think how this would affect non-RDF requests. Clearly an application/pdf or a multi-part body would not attach dataset/quadStream so as long as a body exists the request should continue.