Skip to content

Commit

Permalink
gist put req should not fail because there is not response body
Browse files Browse the repository at this point in the history
  • Loading branch information
softprops committed Dec 3, 2015
1 parent 874e679 commit 3246024
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/gists.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Gists interface

use self::super::{Github, Result};
use self::super::{Error, Github, Result};
use rustc_serialize::json;
use rep::{Gist, GistFork, GistReq};

Expand Down Expand Up @@ -40,14 +40,16 @@ impl<'a> Gists<'a> {
}

pub fn star(&self, id: &str) -> Result<()> {
self.github
.put::<()>(&self.path(&format!("/{}/star", id)), &[])
match self.github
.put::<String>(&self.path(&format!("/{}/star", id)), &[]).map(|_|()) {
Err(Error::Decoding(_)) => Ok(()),
otherwise => otherwise
}
}

pub fn unstar(&self, id: &str) -> Result<()> {
self.github
.delete(&self.path(&format!("/{}/star", id)))
.map(|_| ())
}

pub fn fork(&self, id: &str) -> Result<Gist> {
Expand All @@ -61,7 +63,6 @@ impl<'a> Gists<'a> {
pub fn delete(&self, id: &str) -> Result<()> {
self.github
.delete(&self.path(&format!("/{}", id)))
.map(|_| ())
}

pub fn get(&self, id: &str) -> Result<Gist> {
Expand Down

0 comments on commit 3246024

Please sign in to comment.