Skip to content

Commit

Permalink
Add a method to set the URL's query from an object (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville authored Dec 6, 2024
1 parent 42cdf28 commit b051412
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/request/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ impl<B> RequestBuilder<B> {
self
}

/// Set the query parameters of this request to be the URL-encoded representation of the given object.
#[cfg(feature = "form")]
pub fn query<T: serde::Serialize>(mut self, value: &T) -> Result<Self> {
value.serialize(serde_urlencoded::Serializer::new(&mut self.url.query_pairs_mut()))?;
Ok(self)
}

/// Enable HTTP basic authentication.
#[cfg(feature = "basic-auth")]
pub fn basic_auth(self, username: impl std::fmt::Display, password: Option<impl std::fmt::Display>) -> Self {
Expand Down

0 comments on commit b051412

Please sign in to comment.