blob: b0cfa42da6478ea96c79f37f7ef1bd304a5137d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
use authz::AllowRequest;
use authz::ability_client::AbilityClient;
use hello_world::HelloRequest;
use hello_world::greeter_client::GreeterClient;
pub mod authz {
tonic::include_proto!("authz.rpc");
}
pub mod hello_world {
tonic::include_proto!("helloworld");
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
{
let mut client = GreeterClient::connect("http://[::1]:50051").await?;
let request = tonic::Request::new(HelloRequest {
name: "Tonic".into(),
});
let response = client.say_hello(request).await?;
println!("RESPONSE={:?}", response);
}
{
let request = tonic::Request::new(AllowRequest {
subject: "gid://example/User/1".into(),
permission: "gid://example/Permission/1".into(),
resource: "gid://example/Project/1".into(),
});
let mut client = AbilityClient::connect("http://[::1]:50051").await?;
let response = client.allowed(request).await?;
println!("RESPONSE={:?}", response);
}
Ok(())
}
|