2
我有一个现有的喷雾应用程序利用喷雾路由和我最近添加了文件流上传演员based on the example。喷雾路由与文件上传演员
我无法弄清楚的是如何将我现有的根HttpService actor与我的文件上传Actor并没有扩展HttpService。
我现有的根服务男主角看起来是这样的:
class RootService extends Actor with HttpService with Routes with ActorLogging {
def receive = runRoute {
routes
}
}
我的文件上传演员是这样的:
class FileUploadService extends Actor with Logging {
def receive = {
case part @ HttpRequest(POST, Uri.Path("/upload"), headers, entity: HttpEntity.NonEmpty, protocol) => {
val parts = part.asPartStream()
val client = sender
val handler = context.actorOf(Props(new FileUploadHandler(client, parts.head.asInstanceOf[ChunkedRequestStart])))
parts.tail.foreach(handler !)
}
case start @ ChunkedRequestStart(HttpRequest(POST, Uri.Path("/upload"), _, _, _)) => {
val client = sender
val handler = context.actorOf(Props(new FileUploadHandler(client, start)))
sender ! RegisterChunkHandler(handler)
}
}
}
我试图修改我的根服务男主角如下:
class RootService extends Actor with HttpService with Routes with ActorLogging {
val fileUploadActor = context.actorOf(Props[FileUploadService], "fileUploadActor")
def receive = runRoute {
pathPrefix("upload") {
fileUploadActor ! _.request
} ~ {
route
}
}
}
但是这不起作用。最终,响应永远不会回到客户端(即使我指定了ask vs tell)。
关于工作实现的任何建议?
谢谢!