Use failure::Error instead of hyper::error::UriError

This commit is contained in:
Paul Woolcock 2018-02-12 22:28:29 -05:00
parent b828de404e
commit b8a0fc7a8b
2 changed files with 5 additions and 4 deletions

View file

@ -11,7 +11,7 @@ use ::models::repo::{Repository, RepoPath};
const GITHUB_API_BASE_URI: &'static str = "https://api.github.com";
const GITHUB_USER_CONTENT_BASE_URI: &'static str = "https://raw.githubusercontent.com";
pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<Uri, ::hyper::error::UriError> {
pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<Uri, Error> {
let path_str: &str = path.as_ref();
Ok(format!("{}/{}/{}/HEAD/{}",
GITHUB_USER_CONTENT_BASE_URI,

View file

@ -1,11 +1,12 @@
use hyper::Uri;
use relative_path::RelativePathBuf;
use failure::Error;
use ::models::repo::RepoPath;
const GITLAB_USER_CONTENT_BASE_URI: &'static str = "https://gitlab.com";
pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<Uri, ::hyper::error::UriError> {
pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<Uri, Error> {
let path_str: &str = path.as_ref();
// gitlab will return a 308 if the Uri ends with, say, `.../raw/master//Cargo.toml`, so make
// sure that last slash isn't doubled
@ -14,10 +15,10 @@ pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<
} else {
path_str
};
format!("{}/{}/{}/raw/master/{}",
Ok(format!("{}/{}/{}/raw/master/{}",
GITLAB_USER_CONTENT_BASE_URI,
repo_path.qual.as_ref(),
repo_path.name.as_ref(),
slash_path
).parse::<Uri>()
).parse::<Uri>()?)
}