pakoito
05/09/2019, 9:08 AMfun <DTO> IO<DTO>.withToken(restart: () -> IO<Dto>): IO<DTO> = handleErrorWith {
if (it is HttpException && it.code() == 401) {
restart()
} else {
raiseError(it)
}
}
withToken { accessTokenRepository.refreshAccessToken().flatMap { newToken -> someCall(newToken) } }