File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ pub struct EndpointMiddleware {
136136    pub  token :  String , 
137137    pub  version :  String , 
138138    pub  wrap :  Option < String > , 
139+     pub  namespace :  Option < String > , 
139140} 
140141impl  MiddleWare  for  EndpointMiddleware  { 
141142    fn  request < E :  Endpoint > ( 
@@ -174,6 +175,15 @@ impl MiddleWare for EndpointMiddleware {
174175            ) ; 
175176        } 
176177
178+         // Optionally wrap response 
179+         if  let  Some ( namespace)  = & self . namespace  { 
180+             info ! ( "Middleware: adding namespace header {}" ,  namespace) ; 
181+             req. headers_mut ( ) . append ( 
182+                 "X-Vault-Namespace" , 
183+                 http:: HeaderValue :: from_str ( namespace. as_str ( ) ) . unwrap ( ) , 
184+             ) ; 
185+         } 
186+ 
177187        Ok ( ( ) ) 
178188    } 
179189
Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ impl VaultClient {
120120            token :  settings. token . clone ( ) , 
121121            version :  version_str, 
122122            wrap :  None , 
123+             namespace :  settings. namespace . clone ( ) , 
123124        } ; 
124125
125126        let  http_client = http_client
@@ -163,6 +164,8 @@ pub struct VaultClientSettings {
163164    pub  version :  u8 , 
164165    #[ builder( default  = "false" ) ]  
165166    pub  wrapping :  bool , 
167+     #[ builder( default ) ]  
168+     pub  namespace :  Option < String > , 
166169} 
167170
168171impl  VaultClientSettingsBuilder  { 
@@ -184,6 +187,11 @@ impl VaultClientSettingsBuilder {
184187        self 
185188    } 
186189
190+     pub  fn  set_namespace ( & mut  self ,  str :  String )  -> & mut  Self  { 
191+         self . namespace  = Some ( Some ( str) ) ; 
192+         self 
193+     } 
194+ 
187195    fn  default_address ( & self )  -> Result < Url ,  String >  { 
188196        let  address = if  let  Ok ( address)  = env:: var ( "VAULT_ADDR" )  { 
189197            info ! ( "Using vault address from $VAULT_ADDR: {address}" ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments