File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,12 @@ pub struct AdvisoryDatabase {
37
37
impl AdvisoryDatabase {
38
38
/// Fetch the advisory database from the server where it is stored
39
39
pub fn fetch ( ) -> Result < Self > {
40
- let mut response = try!( reqwest:: get ( ADVISORY_DB_URL ) . map_err ( |_| Error :: Request ) ) ;
40
+ Self :: fetch_from_url ( ADVISORY_DB_URL )
41
+ }
42
+
43
+ /// Fetch advisory database from a custom URL
44
+ pub fn fetch_from_url ( url : & str ) -> Result < Self > {
45
+ let mut response = try!( reqwest:: get ( url) . map_err ( |_| Error :: Request ) ) ;
41
46
42
47
if !response. status ( ) . is_success ( ) {
43
48
return Err ( Error :: Response ) ;
@@ -47,7 +52,7 @@ impl AdvisoryDatabase {
47
52
try!( response. read_to_end ( & mut body) . map_err ( |_| Error :: Response ) ) ;
48
53
let response_str = try!( str:: from_utf8 ( & body) . map_err ( |_| Error :: Parse ) ) ;
49
54
50
- AdvisoryDatabase :: from_toml ( response_str)
55
+ Self :: from_toml ( response_str)
51
56
}
52
57
53
58
/// Parse the advisory database from a TOML serialization of it
You can’t perform that action at this time.
0 commit comments