SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
805 stars 171 forks source link

message body content in POST method. #216

Closed bharath-c closed 7 years ago

bharath-c commented 7 years ago

HI, I was trying to extend restheart with ApplicationLogicHandler clas. in handleRequest i wanted to parse POST method. But i couldnt find any function to fetch message body data. Im not sure if that a bug or intended functionality. Sorry if Im posting in wrong forum.

ujibang commented 7 years ago

Hi @bharath-c

to implement an Application Logic you need to implement the mehtod

public void handleRequest(HttpServerExchange exchange, RequestContext context)

The RequestContext object allows you to get the input body with the method public BsonValue getContent()

bharath-c commented 7 years ago

Thanks for ur reply. I had done same but Im getting null pointer exception. Message body is {"data":"restheart"} Pls guide

bharath-c commented 7 years ago

this helped me. StringWriter writer = new StringWriter(); IOUtils.copy(exchange.getInputStream(), writer); String payLoad = writer.toString();

Anyways thanks a lot.