Skip to content

Commit 598a448

Browse files
author
Cursor Agent
committed
refactor: move api-key header name into API_KEY_HEADER const
Made-with: Cursor
1 parent e8b7edf commit 598a448

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/auth.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ use tonic::metadata::MetadataKey;
22
use tonic::service::Interceptor;
33
use tonic::{Request, Status};
44

5+
/// Header name used for API key / token authentication.
6+
pub const API_KEY_HEADER: &str = "api-key";
7+
58
pub 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
})?,

src/qdrant_client/snapshot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use tonic::codegen::InterceptedService;
44
use tonic::transport::Channel;
55
use tonic::Status;
66

7-
use crate::auth::MetadataInterceptor;
7+
use crate::auth::{MetadataInterceptor, API_KEY_HEADER};
88
use crate::qdrant::snapshots_client::SnapshotsClient;
99
use 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());

0 commit comments

Comments
 (0)