Skip to content

Instantly share code, notes, and snippets.

@johnlcox
Created November 15, 2013 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnlcox/7493793 to your computer and use it in GitHub Desktop.
Save johnlcox/7493793 to your computer and use it in GitHub Desktop.
Scala Futures
def getNearby(avatarId: UUID, radius: Double) = Action.async {
Avatar.getById(avatarId).flatMap {
case Some(avatar) => avatar.location match {
case Some(location) => AvatarService.findAvatarsNearLocation(location, radius).map {nearby => Ok(Json.toJson(nearby))}
case None => Future.successful(NotFound)
}
case None => Future.successful(NotFound)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment