Created
May 22, 2020 21:52
-
-
Save dkomanov/cad28c3cdfb6e893fa65aebbeeffd1b2 to your computer and use it in GitHub Desktop.
[writing-async-app-in-scala-part-1] naive rewrite to async
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
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