File tree 2 files changed +22
-1
lines changed 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 95
95
self . http_client . as_ref ( )
96
96
}
97
97
98
+ pub fn replace_policy (
99
+ & mut self ,
100
+ policy : Arc < dyn Policy < C > > ,
101
+ position : usize ,
102
+ ) -> Arc < dyn Policy < C > > {
103
+ std:: mem:: replace ( & mut self . pipeline [ position] , policy)
104
+ }
105
+
106
+ pub fn policies ( & self ) -> & [ Arc < dyn Policy < C > > ] {
107
+ & self . pipeline
108
+ }
109
+
98
110
pub async fn send (
99
111
& self ,
100
112
ctx : & mut PipelineContext < C > ,
Original file line number Diff line number Diff line change @@ -139,7 +139,16 @@ impl CosmosClient {
139
139
140
140
/// Set the auth token used
141
141
pub fn auth_token ( & mut self , auth_token : AuthorizationToken ) {
142
- self . auth_token = auth_token;
142
+ // TODO: To remove once everything uses the AutorizationPolicy
143
+ self . auth_token = auth_token. clone ( ) ;
144
+
145
+ // we replace the AuthorizationPolicy. This is
146
+ // the last-1 policy by construction.
147
+ let auth_policy: Arc < dyn azure_core:: Policy < CosmosContext > > =
148
+ Arc :: new ( crate :: AuthorizationPolicy :: new ( auth_token) ) ;
149
+
150
+ self . pipeline
151
+ . replace_policy ( auth_policy, self . pipeline . policies ( ) . len ( ) - 2 ) ;
143
152
}
144
153
145
154
/// Create a database
You can’t perform that action at this time.
0 commit comments