path("foo" ~ Slash.?) {
complete(HttpEntity(ContentTypes.`application/octet-stream`, ByteString(Files.readAllBytes(Paths.get("foo")))))
}
说foo
是1GB的文件。我在响应的watchTermination
周围添加了一个Flow
,但在发送响应之前得到了通知,但实际上我想在将完整响应发送给客户端之后]收到通知。 。
[进一步调查显示,watchTermination
建立在仅支持GraphStage
的onUpstreamFinish
之上,并且只有在出现异常时才调用onDownstreamFinish
。参见GraphStages.scala#L128
这是我完整代码的回购:https://github.com/ssgao/akka-http-quickstart-scala/tree/master/src/main/scala/com/example
path(“ foo”〜Slash。?){complete(HttpEntity(ContentTypes.`application / octet-stream`,ByteString(Files.readAllBytes(Paths.get(“ foo”)))))}说foo是一个1GB文件。我添加了watchTermination ...
[SoftwareMill的共同创始人亚当·沃斯基(Adam Warski)写了一篇名为"Measuring response time in akka-http,"的博客文章,其中提供了Akka HTTP指令和随附的方法,它们可以一起记录响应时间。发送完整响应(可能包含数据流)后,将发生帖子中所述的日志记录。