Skip to content

Instantly share code, notes, and snippets.

@lforite
Last active October 22, 2021 09:43
Show Gist options
  • Save lforite/acf54e7d4d7b61c146e99ad8c205f5cd to your computer and use it in GitHub Desktop.
Save lforite/acf54e7d4d7b61c146e99ad8c205f5cd to your computer and use it in GitHub Desktop.
Scala web series Pt. 1 authorize a request based on its truthfulness
implicit AuthorizationOps(predicate: AuthorizationPredicate) {
def authorize[T](token: Token)(f: => Future[T]): Future[T] {
if(predicate.evaluate(token)) {
f()
} else {
Future.failed(AuthorizationException("..."))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment