Skip to content

Instantly share code, notes, and snippets.

@matiwinnetou
Created August 17, 2014 10:44
Show Gist options
  • Save matiwinnetou/013aa076d99830b7a17d to your computer and use it in GitHub Desktop.
Save matiwinnetou/013aa076d99830b7a17d to your computer and use it in GitHub Desktop.
plain old play java promises
public static F.Promise<Result> index6() {
String makesUrl = "http://m.mobile.de/svc/r/makes/Car";
String modelsUrl = "http://m.mobile.de/svc/r/models/375";
F.Promise<SvcApi.Makes> makesP = WS
.url(makesUrl).get()
.map(response -> gson.fromJson(response.getBody(), SvcApi.Makes.class));
F.Promise<SvcApi.Models> modelsP = WS
.url(modelsUrl).get()
.map(response -> gson.fromJson(response.getBody(), SvcApi.Models.class));
return Promises.zip(makesP, modelsP, (makes, models) -> ok(Json.toJson(ImmutableList.of(makes, models))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment