'Rust http crate create a request with post parameters
I have this;
Request::builder()
.method(http::Method::POST)
.uri("/create_mapping")
.body()
And I want to add POST parameters into the body(). Say something like a=1&b=2.
Solution 1:[1]
The easiest way seems to be to use from_urlencoded and do something like:
let encoded = form_urlencoded::Serializer::new(String::new())
.append_pair("a", "1")
.append_pair("b", "2")
.finish();
and then create the body like this: Body::from(encoded)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alper |
