を使用することができますリクエストボディを取得するにはextractRequestEntity
あなたのルートを作成する指示。あなたは単にActor
にテキストの各行を派遣することができ、エンティティ・ストリームたら:
import akka.stream.scaladsl.Framing.delimiter
import akka.util.ByteString
import akka.actor.ActorRef
import akka.http.scaladsl.server.Directives.{extractRequestEntity, onComplete}
val maxLineLength = 256
val streamSplitter = delimiter(ByteString("\n"), maxLineLength)
val actorRef : ActorRef = ??? //not specified in question
val route : Route =
extractRequestEntity { entity =>
onComplete {
entity
.dataBytes
.via(streamSplitter)
.map(_.utf8String)
.runForeach(line => actorRef ! line)
} { _ =>
complete("all lines sent to actor")
}
}
を質問応答は、単に上記の例ので、俳優処理の結果に依存しているかどうかを指定しません。その行をアクターに送り、単純なメッセージを含む応答で要求を完了します。
route
はform the basis of a serverになります。
"huge"を定義してください。一度にすべての要求をメモリに保持するには大きすぎますか? –
それほど巨大ではありません...実際には、送信者がファイルサイズを制御できるので、巨大な場合はチャンクで送信できます。 – Max