Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.66 KB | None | 0 0
  1. fun createJwt(userId: UUID): Either<TokenCreationException, String> =
  2.     audience.flatMap { audience ->
  3.         algorithmSecret.flatMap { secret ->
  4.             algorithm(secret).map { algorithm ->
  5.                 Tuple2(audience, algorithm)
  6.             }
  7.         }
  8.     }.mapLeft { TokenCreationException(it) }
  9.         .flatMap { dependencies ->
  10.             // tutaj logika biznesowa w której otrzymuję Either<TokenCreationException, String>
  11.         }
  12.  
  13. val audience: Either<ConfigurationException, String> = ...
  14. val algorithmSecret: Either<ConfigurationException, String> = ...
  15. val algorithm: Either<ConfigurationException, String> = { secret: String -> ... }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement