Created
November 13, 2014 20:28
-
-
Save whysoserious/e5a7e0ded809acd9ebb8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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._ | |
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