Best REST Client Crate

Can anyone recommend the best crate for writing a REST client? I've found lots on the API side but for the current app I am trying to rewrite from GO I just need the client side. My next step will be rewriting the server side if this goes well.

Fingers crossed,

Glenn

isahc is pretty good, and light-weight.

1 Like

Reqwest seems rather de-facto:

Comes with nice features such as automatically supporting HTTP proxies. Might be heavier than alternatives, though, because it pulls in Tokio.

Thanks, Will give it a look

Glenn

I am having a bit of trouble related to this crate and can't seem to find any examples of making it work. I found a good example using the get method but apparently the post method doesn't return a result type and I"m not sure how to handle it.

The rust docs read:

let params = [("foo", "bar"), ("baz", "quux")];
let client = reqwest::Client::new();
let res = client.post("http://httpbin.org/post")
    .form(&params)
    .send()
    .await?;

The first issue is the ? at the end gives error messages and removing it seems to let it work. I can compile and run with no errors. However, I have no idea whether it is working or not because I can't seem to get anything back from res variable.

If I attempt to do something with res.Status() it says no method exists and if I try to put inside match statement it says it is not a proper response for that.

Does anyone have a real world example of making a post call and receiving back a response as well as dealing with error conditions?

Thanks,

Glenn

1 Like

There's an example in the examples folder: