【发布时间】:2021-11-12 02:49:50
【问题描述】:
我正在使用 akka 版本 2.6.17 和 akka http 10.2.7 创建一个发布请求。我的系统绑定到 8080 端口,可以很好地接收来自 Postman 的 post 请求。但是,当从 akka 本身(发送 post 请求的参与者)内部发送 post 请求时,POST 路径永远不会被命中。 这是发帖请求
public void postStockCheck(){
String data = "{\"id\": \"yes\"}";
HttpRequest.POST("http://localhost:8080/hello")
.withEntity(HttpEntities.create(ContentTypes.TEXT_PLAIN_UTF8, data));
}
这是路径:
return route(
path("hello", () ->
post(() ->
entity(Unmarshaller.entityToString(), (string) -> {
System.out.println("request body: " + string);
return complete("Success");
})
)));
}
如前所述,该路径将从邮递员处工作。如果我遗漏了什么,我们将不胜感激!
【问题讨论】: