Closed lucasantarella closed 4 years ago
Have you checked the https://spiral.dev/docs/http-configuration#middleware
Specifically Spiral\Bootloader\Http\JsonPayloadsBootloader
. Sounds like we might need to enable it by the default.
Also, the documentation includes a full-text search, it will guide you to the proper article. Let me know how we can improve it.
Thanks for the help. I found it. It definetely doesn't work as I expected, though. Without enabling it, the actual PSR7 request interface has an empty body. Usually this would be the string request data, but its empty.
Using the JSON bootloader makes the input manager work, but the raw request should always contain the request payload, IMO.
This could use its own section in the documentation, or at least make it a sub section under the response. I would be happy to help add it as I become more familiar with its workings.
Using the JSON bootloader makes the input manager work, but the raw request should always contain the request payload, IMO.
This is weird since we have a proper test for it: https://github.com/spiral/roadrunner/blob/master/tests/http/payload.php
Is it possible that the content is in the request but you must reset the body position (seek)? Have you tried to convert it into the string? The body must be in the request if the middleware can parse it.
This could use its own section in the documentation, or at least make it a sub-section under the response. I would be happy to help add it as I become more familiar with its workings.
We are currently working on completing the documentation and announcing the platform. Any help with the documentation will be appreciated as we have to cover a massive amount of information.
How are you trying to read the raw body? Check how middleware doing it: https://github.com/spiral/framework/blob/master/src/Http/Middleware/JsonPayloadMiddleware.php#L47
I have a strong feeling that Nyholm getContents()
and __toString()
methods behave differently.
App build includes this middleware by default now.
Hello,
I cannot access the raw JSON payload of a request either directly through a PSR7 ServerRequest nor through the input manager. This is a barebones project scaffolded through composer with no modifications. Nothing in the documentation states any bootloaders to enable/disable to be able to access JSON. Please advise.