Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
add JSON support for /v1/endpoints (fixes #28)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetr committed Sep 8, 2013
1 parent 1700c35 commit 2864c15
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import mesosphere.marathon.tasks.TaskTracker
*/

@Path("v1/endpoints")
@Produces(Array(MediaType.TEXT_PLAIN))
class EndpointsResource @Inject()(
schedulerService: MarathonSchedulerService,
taskTracker: TaskTracker) {

@GET
@Produces(Array(MediaType.TEXT_PLAIN))
def endpoints() = {
val sb = new StringBuilder
for (app <- schedulerService.listApps()) {
Expand All @@ -29,4 +29,13 @@ class EndpointsResource @Inject()(
}
sb.toString()
}

@GET
@Produces(Array(MediaType.APPLICATION_JSON))
def endpointsJson() = {
(for (app <- schedulerService.listApps) yield {
var upstreams = for (task <- taskTracker.get(app.id)) yield "%s:%d".format(task.getHost, task.getPort)
app.id -> Map("port" -> app.port, "upstreams" -> upstreams)
}) toMap
}
}

0 comments on commit 2864c15

Please sign in to comment.