Created
November 20, 2014 23:11
-
-
Save WadeWaldron/cfe61bf8af2e221596fd to your computer and use it in GitHub Desktop.
Streaming Play Enumerators through Spray (package)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor.{ActorContext, ActorRefFactory, Props} | |
import play.api.libs.iteratee.Enumerator | |
import spray.http.{HttpData, ContentType} | |
import spray.routing.RequestContext | |
import scala.concurrent.ExecutionContext | |
package object chunkedresponses { | |
implicit class ChunkedRequestContext(requestContext: RequestContext) { | |
def completeChunked(contentType: ContentType, enumerator: Enumerator[HttpData]) | |
(implicit executionContext: ExecutionContext, actorRefFactory: ActorRefFactory) { | |
val chunkedResponder = actorRefFactory.actorOf(Props(new ChunkedResponder(contentType, requestContext.responder))) | |
val iteratee = new ChunkIteratee(chunkedResponder) | |
enumerator.run(iteratee) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment