Created
March 23, 2014 12:45
-
-
Save cheleb/9722598 to your computer and use it in GitHub Desktop.
This file contains 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
//Avec pattern matching | |
get("/track/:id") { request => | |
val result = request.routeParams.getOrElse("id") match { | |
case None => Map("track2" -> "larzac", "track1" -> "salagou") | |
case Some(id) => Map("track1" -> "salagou") | |
} | |
render.json(result) | |
} | |
//Sans pattern matching | |
render.json(o.map(id => Map("track1" -> "salagou")).getOrElse(Map("track2" -> "larzac", "track1" -> "salagou"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment