Skip to content

Instantly share code, notes, and snippets.

Forked from suni-masuno/some.scala
Last active September 9, 2019 14:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
class SomeClass {
private def get(url: String): Future[Option[String]] =
for {
serviceResponse <- sendGetRequest(url)
} yield maybeBody(url, serviceResponse)
private def maybeBody(url: String, response: HttpResponse[String]): String =
if (response.is2xx) Some(response.body)
else None
private def sendGetRequest(url: String): Future[HttpResponse[String]] =
Future {
private def criticalHeaders = Seq(
"x-http-request-id" -> Context.getRequestContext.getRequestId,
"x-http-caller-id" -> Context.getRequestContext.getCallerId,
"Accept" -> "application/json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment