【发布时间】:2017-07-04 19:36:36
【问题描述】:
我想使用 Alpakka 通过 Akka Steams 处理 S3 上传和下载。但是,我在 Akka Http 路由中使用 S3Client 生成的 Source 时遇到了困难。我得到的错误信息是:
[error] found : akka.stream.scaladsl.Source[akka.util.ByteString,_$1] where type _$1
[error] required: akka.http.scaladsl.marshalling.ToResponseMarshallable
[error] complete(source)
我认为这是一些烦人的琐碎事情,比如缺少隐式导入,但我无法确定我缺少什么。
我创建了一些小例子来说明这个问题:
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
import akka.util.ByteString
import scala.concurrent.ExecutionContext
class Test {
implicit val actorSystem: ActorSystem = ActorSystem()
implicit val materializer: ActorMaterializer = ActorMaterializer()
implicit val executionContext: ExecutionContext = actorSystem.dispatcher
val route = (path("test") & get) {
def source: Source[ByteString, _] = ??? // just assume that I am able to get that value
complete(source) // here error happens
}
Http().bindAndHandle(route, "localhost", 8000)
}
您有什么建议,我可以尝试什么?我正在使用
libraryDependencies += "com.typesafe.akka"%% "akka-http" % "10.0.5"
【问题讨论】:
标签: scala akka-http akka-stream