@@ -40,6 +40,9 @@ pub struct UrlImport {
4040 pub ignore_errors : bool ,
4141
4242 pub checksum : String ,
43+
44+ #[ serde( default ) ]
45+ pub headers : indexmap:: IndexMap < String , String > ,
4346}
4447
4548#[ derive( Debug , Deserialize , Clone , Default ) ]
@@ -129,6 +132,16 @@ impl LocalFileImport {
129132 match loading_location {
130133 Location :: LocalFile ( path) => fs:: read_to_string ( path) . map_err ( DevrcError :: IoError ) ,
131134 Location :: Remote { url, auth } => {
135+ if let Some ( cache_ttl) = config. cache_ttl {
136+ if let Some ( content) = crate :: cache:: load ( & url, & config, None , & cache_ttl) {
137+ config. log_level . debug (
138+ & format ! ( "\n ==> Loading ENV URL CACHE: `{}` ..." , & url) ,
139+ & config. designer . banner ( ) ,
140+ ) ;
141+ return Ok ( content) ;
142+ }
143+ }
144+
132145 let client = reqwest:: blocking:: Client :: new ( ) ;
133146 let mut headers_map: HeaderMap = HeaderMap :: new ( ) ;
134147
@@ -261,6 +274,18 @@ impl UrlImport {
261274 let parsed_url =
262275 Url :: parse ( & self . url ) . map_err ( |_| DevrcError :: InvalidIncludeUrl ( self . url . clone ( ) ) ) ?;
263276
277+ if let Some ( cache_ttl) = config. cache_ttl {
278+ if let Some ( content) =
279+ crate :: cache:: load ( & parsed_url, & config, Some ( & self . checksum ) , & cache_ttl)
280+ {
281+ config. log_level . debug (
282+ & format ! ( "\n ==> Loading ENV URL CACHE: `{}` ..." , & parsed_url) ,
283+ & config. designer . banner ( ) ,
284+ ) ;
285+ return Ok ( content) ;
286+ }
287+ }
288+
264289 config. log_level . debug (
265290 & format ! ( "\n ==> Loading ENV FILE: `{:}` ..." , & parsed_url) ,
266291 & config. designer . banner ( ) ,
@@ -280,6 +305,10 @@ impl UrlImport {
280305 } ) ;
281306 }
282307
308+ if config. cache_ttl . is_some ( ) {
309+ crate :: cache:: save ( & parsed_url, & content) ?;
310+ }
311+
283312 Ok ( content)
284313 }
285314 Ok ( response) => {
0 commit comments