Skip to content

Commit

Permalink
client: add convenience method for DELETE
Browse files Browse the repository at this point in the history
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
  • Loading branch information
Keruspe committed Feb 8, 2017
1 parent cee8355 commit a3983f3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ impl Client {
pub fn post<U: IntoUrl>(&self, url: U) -> RequestBuilder {
self.request(Method::Post, url)
}

/// Convenience method to make a `PUT` request to a URL.
pub fn put<U: IntoUrl>(&self, url: U) -> RequestBuilder {
self.request(Method::Put, url)
}

/// Convenience method to make a `DELETE` request to a URL.
pub fn delete<U: IntoUrl>(&self, url: U) -> RequestBuilder {
self.request(Method::Delete, url)
}

/// Convenience method to make a `HEAD` request to a URL.
pub fn head<U: IntoUrl>(&self, url: U) -> RequestBuilder {
self.request(Method::Head, url)
Expand Down Expand Up @@ -411,6 +416,16 @@ mod tests {
assert_eq!(r.url, Url::parse(some_url));
}

#[test]
fn basic_delete_request() {
let client = Client::new().unwrap();
let some_url = "https://google.com";
let r = client.delete(some_url);

assert_eq!(r.method, Method::Delete);
assert_eq!(r.url, Url::parse(some_url));
}

#[test]
fn add_header() {
let client = Client::new().unwrap();
Expand Down

0 comments on commit a3983f3

Please sign in to comment.