method Ctx.userId
The id of the calling user; AccessDenied when the caller is not a user (ctx.caller.userId(), §13.2).
Example:
service Whoami {
@public rpc me() -> str
}
impl Whoami {
rpc me() {
match ctx.userId() {
str id => id
AccessDenied _ => "anonymous"
}
}
}
fn main() io, net {
print("{Whoami.me()!}")
}Вывод
anonymous
pub(api) fn userId() -> str | AccessDeniedС версии. 1.0.0-beta
Возвращает
str
Ошибки
AccessDenied@error- `AccessDenied` when the caller is not a user.
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/rpc.oxl:293