use RequestBuilder.query to manage url encoding
This commit is contained in:
parent
aa1c0dedfd
commit
471be87ecf
1 changed files with 6 additions and 19 deletions
|
@ -79,17 +79,6 @@ impl Releaser for Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn asset_url(
|
|
||||||
github_repo: &str,
|
|
||||||
release_id: usize,
|
|
||||||
name: &str,
|
|
||||||
) -> String {
|
|
||||||
format!(
|
|
||||||
"http://uploads.github.com/repos/{}/releases/{}/assets?name={}",
|
|
||||||
github_repo, release_id, name
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<A: Into<Body>> AssetUploader<A> for Client {
|
impl<A: Into<Body>> AssetUploader<A> for Client {
|
||||||
// https://developer.github.com/v3/repos/releases/#upload-a-release-asset
|
// https://developer.github.com/v3/repos/releases/#upload-a-release-asset
|
||||||
fn upload(
|
fn upload(
|
||||||
|
@ -102,9 +91,13 @@ impl<A: Into<Body>> AssetUploader<A> for Client {
|
||||||
asset: A,
|
asset: A,
|
||||||
) -> Result<StatusCode, Box<dyn Error>> {
|
) -> Result<StatusCode, Box<dyn Error>> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.post(&asset_url(github_repo, release_id, name))
|
.post(&format!(
|
||||||
|
"http://uploads.github.com/repos/{}/releases/{}/assets",
|
||||||
|
github_repo, release_id
|
||||||
|
))
|
||||||
.header("Authorization", format!("bearer {}", github_token))
|
.header("Authorization", format!("bearer {}", github_token))
|
||||||
.header("Content-Type", mime.to_string())
|
.header("Content-Type", mime.to_string())
|
||||||
|
.query(&[("name", name)])
|
||||||
.body(asset)
|
.body(asset)
|
||||||
.send()?
|
.send()?
|
||||||
.status())
|
.status())
|
||||||
|
@ -113,12 +106,6 @@ impl<A: Into<Body>> AssetUploader<A> for Client {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
#[test]
|
#[test]
|
||||||
fn asset_url_formats_urls() {
|
fn it_works() {}
|
||||||
assert_eq!(
|
|
||||||
"http://uploads.github.com/repos/foo/bar/releases/1/assets?name=release.txt",
|
|
||||||
asset_url("foo/bar", 1, "release.txt")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue