Created
June 30, 2013 17:16
-
-
Save d6y/5896016 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
| package code.rest | |
| import net.liftweb.http.rest.RestHelper | |
| import net.liftweb.json.JsonDSL._ | |
| import net.liftweb.json.JsonAST._ | |
| object PoemResource extends RestHelper { | |
| // The database of poem titles: | |
| val poems = Map( | |
| "Larkin" -> List("This Be The Verse", "Aubade") | |
| ) | |
| // Helper to convert from titles to a JSON representation: | |
| def asJSON(titles: List[String]) : JValue = | |
| ("titles" -> titles) | |
| // Match on a request, return a LiftResponse: | |
| serve { | |
| case "poems" :: "by" :: author :: Nil Get request => | |
| poems.get(author).map(asJSON) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment