Skip to content

Instantly share code, notes, and snippets.

@dkomanov
Created May 22, 2020 21:52
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 dkomanov/cad28c3cdfb6e893fa65aebbeeffd1b2 to your computer and use it in GitHub Desktop.
Save dkomanov/cad28c3cdfb6e893fa65aebbeeffd1b2 to your computer and use it in GitHub Desktop.
[writing-async-app-in-scala-part-1] naive rewrite to async
def regularRpcEndpoint(request: Request): Future[Response] = {
validateRequest(request)
isPermittedViaRpc.flatMap { isPermitted =>
if (!isPermitted) {
Future.failed(new PermissionDeniedException("..."))
} else {
retrieveFromDatabase(request.id)
.map(convertPayloadFromDb)
.map(Response)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment