realm-client 0.1.0

realm-client: http client for realm backend
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub fn action<T, B>(url: &str, body: B, tid: Option<String>) -> crate::Result<T>
where
    T: serde::de::DeserializeOwned,
    B: serde::Serialize,
{
    let url = crate::url(url);

    if crate::is_test() {
        return crate::mock(tid, serde_json::json! ({"url": url.as_str(), "body": body}));
    }

    let json = match serde_json::to_string(&body) {
        Ok(v) => v,
        Err(e) => return Err(crate::Error::SerializeError(e)),
    };

    crate::handle(crate::client(url.as_str(), reqwest::Method::POST).body(json))
}