Created
October 25, 2015 12:10
-
-
Save schmitch/738f88abc5786012d684 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
package controllers | |
import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
import play.api.libs.json.{JsObject, JsString, Json} | |
import play.api.mvc.{Action, Results} | |
object EVRequest extends Results { | |
def json[A](action: Action[A]) = Action.async(action.parser) { request => | |
action(request).map { result => | |
val body = result.body.map { data => | |
val js = Json.parse(data).asInstanceOf[JsObject] + ("server" -> JsString("1.3")) | |
js.toString().getBytes | |
} | |
result.copy(body = body) | |
} | |
} | |
} | |
object EVRequest2 extends Results { | |
def json[A](action: Action[A]) = Action.async(action.parser) { request => | |
action(request).map { result => | |
val body = result.body.map { data => | |
val js = Json.parse(data).asInstanceOf[JsObject] + ("server" -> JsString("1.4")) | |
js.toString().getBytes | |
} | |
result.copy(body = body) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment