Closed spartan closed 6 years ago
I think this is a duplicate of #278
Parsing the body contents is out of scope for the ServerRequest
class.
The reason is that how to parse the body will vary based on the request content type. x-www-form-urlencoded is different from JSON is different from XML, and within XML, how that gets parsed will be highly dependent on the XML schema and how it relates to domain objects.
On top of that, even with JSON, how it is parsed will often be up to the specific application. Some will want JSON objects mapped to stdClass
instances, while others (like yourself) will want associative arrays.
As such, it's up to the application to determine how to parse the body. This is a job generally left to middleware.
@weierophinney Indeed it makes more sense to handle it in the middleware. Thank you.
I believe in the case below the
getParsedBody
should return an array. Currently returnsNULL
.