@@ -263,7 +263,7 @@ impl<R: Runtime> UpdateBuilder<R> {
263263 self
264264 }
265265
266- /// Add a `Header` to the request .
266+ /// Adds a header for the requests to the updater endpoints .
267267 pub fn header < K , V > ( mut self , key : K , value : V ) -> Result < Self >
268268 where
269269 HeaderName : TryFrom < K > ,
@@ -275,6 +275,12 @@ impl<R: Runtime> UpdateBuilder<R> {
275275 Ok ( self )
276276 }
277277
278+ /// Adds a list of endpoints to fetch the update.
279+ pub fn endpoints ( mut self , urls : & [ String ] ) -> Self {
280+ self . inner = self . inner . urls ( urls) ;
281+ self
282+ }
283+
278284 /// Check if an update is available.
279285 ///
280286 /// # Examples
@@ -302,6 +308,7 @@ impl<R: Runtime> UpdateBuilder<R> {
302308 /// If ther server responds with status code `204`, this method will return [`Error::UpToDate`]
303309 pub async fn check ( self ) -> Result < UpdateResponse < R > > {
304310 let handle = self . inner . app . clone ( ) ;
311+
305312 // check updates
306313 match self . inner . build ( ) . await {
307314 Ok ( update) => {
@@ -395,6 +402,28 @@ impl<R: Runtime> UpdateResponse<R> {
395402 self . update . body . as_ref ( )
396403 }
397404
405+ /// Add a header to the download request.
406+ pub fn header < K , V > ( mut self , key : K , value : V ) -> Result < Self >
407+ where
408+ HeaderName : TryFrom < K > ,
409+ <HeaderName as TryFrom < K > >:: Error : Into < http:: Error > ,
410+ HeaderValue : TryFrom < V > ,
411+ <HeaderValue as TryFrom < V > >:: Error : Into < http:: Error > ,
412+ {
413+ self . update = self . update . header ( key, value) ?;
414+ Ok ( self )
415+ }
416+
417+ /// Removes a header from the download request.
418+ pub fn remove_header < K > ( mut self , key : K ) -> Result < Self >
419+ where
420+ HeaderName : TryFrom < K > ,
421+ <HeaderName as TryFrom < K > >:: Error : Into < http:: Error > ,
422+ {
423+ self . update = self . update . remove_header ( key) ?;
424+ Ok ( self )
425+ }
426+
398427 /// Downloads and installs the update.
399428 pub async fn download_and_install ( self ) -> Result < ( ) > {
400429 download_and_install ( self . update ) . await
@@ -405,7 +434,7 @@ impl<R: Runtime> UpdateResponse<R> {
405434pub ( crate ) async fn check_update_with_dialog < R : Runtime > ( handle : AppHandle < R > ) {
406435 let updater_config = handle. config ( ) . tauri . updater . clone ( ) ;
407436 let package_info = handle. package_info ( ) . clone ( ) ;
408- if let Some ( endpoints) = updater_config. endpoints . clone ( ) {
437+ if let Some ( endpoints) = & updater_config. endpoints {
409438 let endpoints = endpoints
410439 . iter ( )
411440 . map ( |e| e. to_string ( ) )
@@ -502,13 +531,11 @@ pub fn builder<R: Runtime>(handle: AppHandle<R>) -> UpdateBuilder<R> {
502531 let package_info = handle. package_info ( ) . clone ( ) ;
503532
504533 // prepare our endpoints
505- let endpoints = updater_config
534+ let endpoints: Vec < String > = updater_config
506535 . endpoints
507536 . as_ref ( )
508- . expect ( "Something wrong with endpoints" )
509- . iter ( )
510- . map ( |e| e. to_string ( ) )
511- . collect :: < Vec < String > > ( ) ;
537+ . map ( |endpoints| endpoints. iter ( ) . map ( |e| e. to_string ( ) ) . collect ( ) )
538+ . unwrap_or_default ( ) ;
512539
513540 let mut builder = self :: core:: builder ( handle. clone ( ) )
514541 . urls ( & endpoints[ ..] )
0 commit comments