-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_blocking.rs
More file actions
40 lines (33 loc) · 1012 Bytes
/
Copy pathhello_blocking.rs
File metadata and controls
40 lines (33 loc) · 1012 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
37
38
39
40
//! Calls the live https://test.servicestack.net Services with the sync client:
//!
//! ```bash
//! cargo run --example hello_blocking --features blocking
//! ```
use serde::{Deserialize, Serialize};
use servicestack::blocking::JsonServiceClient;
use servicestack::{IRequest, IReturn};
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(default, rename_all = "camelCase")]
struct Hello {
name: String,
}
impl IRequest for Hello {
const NAME: &'static str = "Hello";
const VERB: &'static str = servicestack::HTTP_GET;
}
impl IReturn for Hello {
type Response = HelloResponse;
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(default, rename_all = "camelCase")]
struct HelloResponse {
result: String,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = JsonServiceClient::new("https://test.servicestack.net");
let res = client.send(&Hello {
name: "World".to_string(),
})?;
println!("{}", res.result);
Ok(())
}