I have a code that handle incoming http requests as follows
public Function < HttpRequest, HttpResponse > handleRequest() {
return new Function < HttpRequest, HttpResponse > () {
private static final long serialVersionUID = 1 L;
@Override
public HttpResponse apply(HttpRequest request) throws Exception {
System.out.print(request);
return HttpResponse.create()
.withEntity(ContentTypes.TEXT_PLAIN_UTF8, "Success")
.withStatus(StatusCodes.OK);
}
}
}
On the console I get a result like this.
HttpRequest(HttpMethod(POST),http://localhost:8081/,List(Host: localhost:8081, Connection: keep-alive, Authorization: Basic YTph, Postman-Token: 1e3189b0-f320-5926-a781-a9c05e5cbd6a, Cache-Control: no-cache, Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop, User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36, Accept: */*, Accept-Encoding: gzip, deflate, br, Accept-Language: en-US, en;q=0.9, Timeout-Access: <function1>),HttpEntity.Strict(application/json,{
"name" : "John Doe"
}),HttpProtocol(HTTP/1.1))
So I want to get the Json to a string variable like this
{"name" : "John Doe"}