-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlog.rs
More file actions
36 lines (28 loc) · 778 Bytes
/
log.rs
File metadata and controls
36 lines (28 loc) · 778 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
30
31
32
33
34
35
36
#![allow(unused_imports)]
use feignhttp::post;
use serde::Serialize;
#[derive(Serialize)]
struct Data {
id: i32,
name: String,
}
#[cfg(feature = "json")]
#[post("https://httpbin.org/anything")]
async fn anything(#[body] data: Data) -> feignhttp::Result<String> {}
// Specify features = ["log"] in Cargo.toml to enable log feature.
// cargo run --example log --features log.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
std::env::set_var("RUST_LOG", "feignhttp=debug");
env_logger::init();
#[cfg(feature = "json")]
{
let data = Data {
id: 1,
name: "test".to_string(),
};
let r = anything(data).await?;
println!("anything result: {}", r);
}
Ok(())
}