I want to create a "mock" server using Ratpack/Groovy and we need to read the data-raw from a call
I haven't had a problem reading headers or parameters, but I need to read the body of a request
Examplle:
curl --location --POST request 'http://localhost:5050/authenticate' \
--header 'Content-type: application/json' \
--raw-data '{
"username": "testbase01@domain.com",
"password": "12345678"
}'
we need to parse and process the username and password fields
We have tried to read the request.body, or the body.text, but we have not been successful.
Basically the example found in the solution at https://stackoverflow.com/questions/23636248/parse-json-in-ratpack-groovy would be what we need, but it hasn't worked for us either
Our environment has the following dependencies
- @Grab('io.ratpack:ratpack-groovy:1.6.1'),
- @Grab('org.slf4j:slf4j-simple:1.7.22'),
- @Grab("io.ratpack:ratpack-jackson:0.9.17")
- and we are using https://github.com/Vad1mo/hello-world-rest as primary image
If you have a small example, to be able to adapt it to our needs