pub struct RequestBuilder { /* private fields */ }Expand description
A fluent Request builder.
let request = Request::builder()
.method(Method::POST)
.uri("/posts?draft=1")
.json(&serde_json::json!({ "title": "Hello" }))
.build();
assert_eq!(request.input("title").as_deref(), Some("Hello"));
assert_eq!(request.input("draft").as_deref(), Some("1"));Implementations§
Source§impl RequestBuilder
impl RequestBuilder
Sourcepub fn header(self, name: &str, value: &str) -> Self
pub fn header(self, name: &str, value: &str) -> Self
Add a header. Ignored if the name or value is not a legal header.
Sourcepub fn json(self, value: &impl Serialize) -> Self
pub fn json(self, value: &impl Serialize) -> Self
Set a JSON body and the matching Content-Type.
Sourcepub fn form(self, pairs: &[(&str, &str)]) -> Self
pub fn form(self, pairs: &[(&str, &str)]) -> Self
Set a urlencoded form body and the matching Content-Type.
Trait Implementations§
Source§impl Debug for RequestBuilder
impl Debug for RequestBuilder
Auto Trait Implementations§
impl !Freeze for RequestBuilder
impl RefUnwindSafe for RequestBuilder
impl Send for RequestBuilder
impl Sync for RequestBuilder
impl Unpin for RequestBuilder
impl UnsafeUnpin for RequestBuilder
impl UnwindSafe for RequestBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more