mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-22 18:36:30 +00:00
Use failure::Error instead of hyper::error::UriError
This commit is contained in:
parent
b828de404e
commit
b8a0fc7a8b
2 changed files with 5 additions and 4 deletions
|
@ -11,7 +11,7 @@ use ::models::repo::{Repository, RepoPath};
|
||||||
const GITHUB_API_BASE_URI: &'static str = "https://api.github.com";
|
const GITHUB_API_BASE_URI: &'static str = "https://api.github.com";
|
||||||
const GITHUB_USER_CONTENT_BASE_URI: &'static str = "https://raw.githubusercontent.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();
|
let path_str: &str = path.as_ref();
|
||||||
Ok(format!("{}/{}/{}/HEAD/{}",
|
Ok(format!("{}/{}/{}/HEAD/{}",
|
||||||
GITHUB_USER_CONTENT_BASE_URI,
|
GITHUB_USER_CONTENT_BASE_URI,
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use hyper::Uri;
|
use hyper::Uri;
|
||||||
use relative_path::RelativePathBuf;
|
use relative_path::RelativePathBuf;
|
||||||
|
use failure::Error;
|
||||||
|
|
||||||
use ::models::repo::RepoPath;
|
use ::models::repo::RepoPath;
|
||||||
|
|
||||||
const GITLAB_USER_CONTENT_BASE_URI: &'static str = "https://gitlab.com";
|
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();
|
let path_str: &str = path.as_ref();
|
||||||
// gitlab will return a 308 if the Uri ends with, say, `.../raw/master//Cargo.toml`, so make
|
// gitlab will return a 308 if the Uri ends with, say, `.../raw/master//Cargo.toml`, so make
|
||||||
// sure that last slash isn't doubled
|
// sure that last slash isn't doubled
|
||||||
|
@ -14,10 +15,10 @@ pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<
|
||||||
} else {
|
} else {
|
||||||
path_str
|
path_str
|
||||||
};
|
};
|
||||||
format!("{}/{}/{}/raw/master/{}",
|
Ok(format!("{}/{}/{}/raw/master/{}",
|
||||||
GITLAB_USER_CONTENT_BASE_URI,
|
GITLAB_USER_CONTENT_BASE_URI,
|
||||||
repo_path.qual.as_ref(),
|
repo_path.qual.as_ref(),
|
||||||
repo_path.name.as_ref(),
|
repo_path.name.as_ref(),
|
||||||
slash_path
|
slash_path
|
||||||
).parse::<Uri>()
|
).parse::<Uri>()?)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue