MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / get_posts

Method get_posts

examples/tonic_example/api/src/lib.rs:39–58  ·  view source on GitHub ↗
(&self, request: Request<PostPerPage>)

Source from the content-addressed store, hash-verified

37#[tonic::async_trait]
38impl Blogpost for MyServer {
39 async fn get_posts(&self, request: Request<PostPerPage>) -> Result<Response<PostList>, Status> {
40 let conn = &self.connection;
41 let posts_per_page = request.into_inner().per_page;
42
43 let mut response = PostList { post: Vec::new() };
44
45 let (posts, _) = Query::find_posts_in_page(conn, 1, posts_per_page)
46 .await
47 .expect("Cannot find posts in page");
48
49 for post in posts {
50 response.post.push(Post {
51 id: post.id,
52 title: post.title,
53 content: post.text,
54 });
55 }
56
57 Ok(Response::new(response))
58 }
59
60 async fn add_post(&self, request: Request<Post>) -> Result<Response<PostId>, Status> {
61 let conn = &self.connection;

Callers 1

mainFunction · 0.80

Calls 3

into_innerMethod · 0.80
pushMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected