Skip to content

Instantly share code, notes, and snippets.

@searler
Created April 6, 2014 23:07
Show Gist options
  • Save searler/10012356 to your computer and use it in GitHub Desktop.
Save searler/10012356 to your computer and use it in GitHub Desktop.
Play Action that implements provides web service for editor.js that discards the 'a' character.
def text = Action(parse.json) { request =>
val caret = (request.body \ "caret").as[Int]
val text = (request.body \ "text").as[String]
val trimmed = text.filterNot(_ == 'a')
Ok(Json.obj("caret" -> (caret-(text.length-trimmed.length)), "text" -> trimmed))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment