Why doesn't RequestBodyParserMiddleware support application/json? #605
-
I've been working with the HTTP server recently and noticed something that made me curious. While implementing API endpoints, I had to write custom middleware to parse JSON request bodies. Looking through the codebase, I found the
But it doesn't have support for application/json, which is pretty much the standard for modern APIs. I'm wondering if this was an intentional design decision? Is there a specific reason JSON parsing was left out, or is it expected that developers implement this themselves? Something as simple as: if ($type === 'application/json') {
$data = json_decode((string)$request->getBody(), true);
return $next($request->withParsedBody($data));
} Would be really helpful for API-focused applications. Just curious about the thought process here. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
This comment was marked as spam.
This comment was marked as spam.
-
I'm just gonna close this cos I found this: reactphp/http#306 and it seems it was actually intentional. |
Beta Was this translation helpful? Give feedback.
I'm just gonna close this cos I found this: reactphp/http#306 and it seems it was actually intentional.