chore(docs): Add helloworld tutorial (#80)
This commit is contained in:
committed by
Lucio Franco
parent
9b0613a16d
commit
8ebedcde2f
@@ -9,7 +9,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut client = GreeterClient::connect("http://[::1]:50051")?;
|
||||
|
||||
let request = tonic::Request::new(HelloRequest {
|
||||
name: "hello".into(),
|
||||
name: "Tonic".into(),
|
||||
});
|
||||
|
||||
let response = client.say_hello(request).await?;
|
||||
|
||||
@@ -10,9 +10,7 @@ use hello_world::{
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MyGreeter {
|
||||
data: String,
|
||||
}
|
||||
pub struct MyGreeter {}
|
||||
|
||||
#[tonic::async_trait]
|
||||
impl Greeter for MyGreeter {
|
||||
@@ -22,12 +20,8 @@ impl Greeter for MyGreeter {
|
||||
) -> Result<Response<HelloReply>, Status> {
|
||||
println!("Got a request: {:?}", request);
|
||||
|
||||
let string = &self.data;
|
||||
|
||||
println!("My data: {:?}", string);
|
||||
|
||||
let reply = hello_world::HelloReply {
|
||||
message: "Zomg, it works!".into(),
|
||||
message: format!("Hello {}!", request.into_inner().name).into(),
|
||||
};
|
||||
Ok(Response::new(reply))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user