Skip to content

Instantly share code, notes, and snippets.

@whysoserious
Created November 13, 2014 20:28
Show Gist options
  • Save whysoserious/e5a7e0ded809acd9ebb8 to your computer and use it in GitHub Desktop.
Save whysoserious/e5a7e0ded809acd9ebb8 to your computer and use it in GitHub Desktop.
import akka.actor._
import akka.util.ByteString
import spray.http.HttpEntity.Empty
import spray.http.MediaTypes._
import spray.http._
import spray.routing.{HttpService, RequestContext, SimpleRoutingApp}
object ChunkedSpray extends App with SimpleRoutingApp {
import StreamingActor._
implicit val actorSystem = ActorSystem()
lazy val stream: Stream[String] = "first" #:: "second" #:: "third" #:: Stream.empty
lazy val emptyStream: Stream[Array[Byte]] = Stream.empty
startServer(interface = "localhost", port = 8080) {
get {
path("stream") {
ctx =>
actorRefFactory.actorOf(fromString(stream, ctx))
} ~
path("empty-stream") {
ctx =>
actorRefFactory.actorOf(fromByteArray(emptyStream, ctx))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment