(&self, request: Request<PostId>)
| 97 | } |
| 98 | |
| 99 | async fn get_post_by_id(&self, request: Request<PostId>) -> Result<Response<Post>, Status> { |
| 100 | let conn = &self.connection; |
| 101 | let id = request.into_inner().id; |
| 102 | |
| 103 | if let Some(post) = Query::find_post_by_id(conn, id).await.ok().flatten() { |
| 104 | Ok(Response::new(Post { |
| 105 | id, |
| 106 | title: post.title, |
| 107 | content: post.text, |
| 108 | })) |
| 109 | } else { |
| 110 | Err(Status::new( |
| 111 | tonic::Code::Aborted, |
| 112 | "Could not find post with id ".to_owned() + &id.to_string(), |
| 113 | )) |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | #[tokio::main] |
nothing calls this directly
no test coverage detected