File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -4,27 +4,20 @@ pub struct CacheHeaderInterceptor {
4
4
}
5
5
6
6
impl tonic:: service:: Interceptor for CacheHeaderInterceptor {
7
- fn call ( & mut self , request : tonic:: Request < ( ) > ) -> Result < tonic:: Request < ( ) > , tonic:: Status > {
8
- let request_metadata = request. metadata ( ) . clone ( ) ;
9
- let mut result = {
10
- let message = request. into_inner ( ) ;
11
- tonic:: Request :: new ( message)
12
- } ;
13
- result. metadata_mut ( ) . insert (
7
+ fn call (
8
+ & mut self ,
9
+ mut request : tonic:: Request < ( ) > ,
10
+ ) -> Result < tonic:: Request < ( ) > , tonic:: Status > {
11
+ request. metadata_mut ( ) . insert (
14
12
"authorization" ,
15
13
tonic:: metadata:: AsciiMetadataValue :: from_str ( self . auth_key . as_str ( ) ) . unwrap ( ) ,
16
14
) ;
17
15
// for reasons unknown, tonic seems to be stripping out the content-type. So we need to add this as
18
16
// a workaround so that the requests are successful
19
- result . metadata_mut ( ) . insert (
17
+ request . metadata_mut ( ) . insert (
20
18
"content-type" ,
21
19
tonic:: metadata:: AsciiMetadataValue :: from_str ( "application/grpc" ) . unwrap ( ) ,
22
20
) ;
23
-
24
- let cache_name = request_metadata. get ( "cache" ) . unwrap ( ) ;
25
-
26
- // need to re-add our `cache` header back into the interceptor or it will be stripped out
27
- result. metadata_mut ( ) . insert ( "cache" , cache_name. clone ( ) ) ;
28
- Ok ( result)
21
+ Ok ( request)
29
22
}
30
23
}
You can’t perform that action at this time.
0 commit comments