Last active
December 29, 2015 09:29
-
-
Save privateblue/7650915 to your computer and use it in GitHub Desktop.
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
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