Skip to content

Commit 021277e

Browse files
committed
feat: get news body api
1 parent 71af51e commit 021277e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/api/news/get_body.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use crate::api::news::News;
2+
use crate::blog_backend;
3+
use crate::infra::http::{body_or_err, RequestBuilderExt};
4+
use anyhow::Result;
5+
6+
impl News {
7+
pub async fn get_body(&self, id: usize) -> Result<String> {
8+
let client = reqwest::Client::new();
9+
10+
let req = {
11+
let url = blog_backend!("newsitems/{}/body", id);
12+
client.get(url).pat_auth(&self.pat)
13+
};
14+
15+
let resp = req.send().await?;
16+
17+
body_or_err(resp).await
18+
}
19+
}

src/api/news/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod get_body;
12
pub mod get_list;
23

34
pub struct News {

0 commit comments

Comments
 (0)