Skip to content

Instantly share code, notes, and snippets.

@healsjnr
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save healsjnr/f82c376995a8130a5be5 to your computer and use it in GitHub Desktop.
Save healsjnr/f82c376995a8130a5be5 to your computer and use it in GitHub Desktop.
Naive WebService Request
def getUserData(userId: Int): Future[JsValue] = {
val request = WS.url("http://example.com/user/1").withHeaders("Content-Type" -> "application/json").get()
request.map { response =>
if (response.status == 200) {
response.json
} else {
throw new Exception("Error received. Status: ${response.status} Body: ${response.json}")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment