Created
August 17, 2014 10:44
-
-
Save matiwinnetou/013aa076d99830b7a17d to your computer and use it in GitHub Desktop.
plain old play java promises
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
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