将请求主体附加到VERTX请求
在下面的顶点URL实例的我的Java示例代码中,URL在调用时返回JSON请求。我试图将请求主体附加到URL,但我被卡住了。这是一个示例片段,
Route handler2 = router
.post("/get-a-file")
.consumes("*/json")
.handler(routingContext -> {
HttpServerResponse response = routingContext.response();
response.setChunked(true);
response.write("bla bla bla...");
response.end();
});
只是在Vert.x上掌握了我的手。协助
IN my java sample code of a vertex URL instance below, The URL returns a json request when called. I am trying to append a request body to the URL but I am stuck. Here is a sample snippet
Route handler2 = router
.post("/get-a-file")
.consumes("*/json")
.handler(routingContext -> {
HttpServerResponse response = routingContext.response();
response.setChunked(true);
response.write("bla bla bla...");
response.end();
});
Just getting my hands on vert.x. Do assist
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于vert.x 您的路线需要bodyhandler ,请访问主体。您应该在自己的处理程序之前添加它,以便当您的业务逻辑运行时,请求主体已经存在。
您的代码看起来应该与此相似:
现在您可以在
routingContext
上访问主体并将其映射到您的DTO。For request bodies in Vert.x your route needs a BodyHandler. You should add it before your own handler so that the request body is already there when your business logic runs.
Your code should look similar to this:
Now you can access the body on
routingContext
and map it to your DTO.