Skip to content

Instantly share code, notes, and snippets.

@danellis
Created May 13, 2014 03:16
Show Gist options
  • Save danellis/1cf8623b0631eff738c9 to your computer and use it in GitHub Desktop.
Save danellis/1cf8623b0631eff738c9 to your computer and use it in GitHub Desktop.
val myRoute =
pathPrefix("rest") {
controller("apps", RestController(AppDao)) ~
controller("clusters", RestController(ClusterDao)) ~
controller("commits", RestController(CommitDao)) ~
controller("deployments", RestController(DeploymentDao)) ~
controller("config-keys", RestController(ConfigKeyDao)) ~
controller("config-values", RestController(ConfigValueDao)) ~
controller("blades", RestController(BladeDao)) ~
controller("stacks", RestController(StackDao)) ~
controller("repositories", RestController(RepositoryDao)) ~
controller("process-types", RestController(ProcessTypeDao)) ~
controller("search", context.actorOf(Props[SearchController]))
} ~
path("events") {
get { ctx =>
val response = HttpResponse(
StatusCodes.OK,
HttpEntity(
ContentType(MediaTypes.CustomMediaType("text/event-stream"), HttpCharsets.`UTF-8`),
""
),
List(HttpHeaders.Connection("Keep-Alive"))
)
ctx.responder ! ChunkedResponseStart(response)
val eventSource = context.actorOf(Props(classOf[EventSource], ctx.responder))
}
} ~
path("") { getFromFile(s"$staticDir/index.html") } ~
pathPrefix("") { getFromDirectory(staticDir) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment