File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ use tonic::metadata::MetadataKey;
22use tonic:: service:: Interceptor ;
33use tonic:: { Request , Status } ;
44
5+ /// Header name used for API key / token authentication.
6+ pub const API_KEY_HEADER : & str = "api-key" ;
7+
58pub struct MetadataInterceptor {
69 api_key : Option < String > ,
710 custom_headers : Vec < ( String , String ) > ,
@@ -20,7 +23,7 @@ impl Interceptor for MetadataInterceptor {
2023 fn call ( & mut self , mut req : Request < ( ) > ) -> anyhow:: Result < Request < ( ) > , Status > {
2124 if let Some ( api_key) = & self . api_key {
2225 req. metadata_mut ( ) . insert (
23- "api-key" ,
26+ API_KEY_HEADER ,
2427 api_key. parse ( ) . map_err ( |_| {
2528 Status :: invalid_argument ( format ! ( "Malformed API key or token: {api_key}" ) )
2629 } ) ?,
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use tonic::codegen::InterceptedService;
44use tonic:: transport:: Channel ;
55use tonic:: Status ;
66
7- use crate :: auth:: MetadataInterceptor ;
7+ use crate :: auth:: { MetadataInterceptor , API_KEY_HEADER } ;
88use crate :: qdrant:: snapshots_client:: SnapshotsClient ;
99use crate :: qdrant:: {
1010 CreateFullSnapshotRequest , CreateSnapshotRequest , CreateSnapshotResponse ,
@@ -167,7 +167,7 @@ impl Qdrant {
167167 let client = reqwest:: Client :: new ( ) ;
168168 let mut request = client. get ( & url) ;
169169 if let Some ( api_key) = & self . config . api_key {
170- request = request. header ( "api-key" , api_key. as_str ( ) ) ;
170+ request = request. header ( API_KEY_HEADER , api_key. as_str ( ) ) ;
171171 }
172172 for ( key, value) in & self . config . custom_headers {
173173 request = request. header ( key. as_str ( ) , value. as_str ( ) ) ;
You can’t perform that action at this time.
0 commit comments