Skip to content

Instantly share code, notes, and snippets.

@schmitch
Created October 25, 2015 12:10
Show Gist options
  • Save schmitch/738f88abc5786012d684 to your computer and use it in GitHub Desktop.
Save schmitch/738f88abc5786012d684 to your computer and use it in GitHub Desktop.
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