-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathconfig.rs
More file actions
29 lines (24 loc) · 814 Bytes
/
Copy pathconfig.rs
File metadata and controls
29 lines (24 loc) · 814 Bytes
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
use feignhttp::{ClientConfig, FeignClientBuilder, feign};
#[feign(url = "https://api.github.com")]
pub trait GitHub {
#[get("/repos/{owner}/{repo}")]
async fn repository(
&self,
#[path] owner: &str,
#[path] repo: &str,
) -> feignhttp::Result<String>;
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Use ClientConfig to configure timeouts.
let config = ClientConfig {
connect_timeout: Some(5000), // 5 seconds
timeout: Some(10000), // 10 seconds
read_timeout: Some(5000), // 5 seconds
};
// Apply config to a trait builder.
let github = GitHub::builder().config(config).build()?;
let r = github.repository("dxx", "feignhttp").await?;
println!("repository: {}\n", r);
Ok(())
}