Skip to content

Instantly share code, notes, and snippets.

@privateblue
Last active December 29, 2015 09:29
Show Gist options
  • Save privateblue/7650915 to your computer and use it in GitHub Desktop.
Save privateblue/7650915 to your computer and use it in GitHub Desktop.
import play.api.mvc._
import play.api.libs.json.Json
import play.api.libs.concurrent.Execution.Implicits.defaultContext
object MyController extends Controller {
def getName(id: Int) = Action.async {
MyRepository.getName(id)
.map { name: String =>
Ok(Json.obj("name" -> name))
}
.recover {
case _ => NotFound
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment