-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathform.rs
More file actions
31 lines (24 loc) · 706 Bytes
/
form.rs
File metadata and controls
31 lines (24 loc) · 706 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
use feignhttp::post;
use serde::Serialize;
// Serialize: Specifies serialization.
#[derive(Debug, Serialize)]
struct User {
id: i32,
name: String,
}
#[post(url = "https://httpbin.org/anything")]
async fn post_user(#[form] id: i32, #[form] name: &str) -> feignhttp::Result<String> {}
#[post(url = "https://httpbin.org/anything")]
async fn post_user2(#[form] user: User) -> feignhttp::Result<String> {}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let r = post_user(1, "jack").await?;
println!("{}", r);
let user = User {
id: 1,
name: "jack".to_string(),
};
let r = post_user2(user).await?;
println!("{}", r);
Ok(())
}