From 378044a41c6aafee24a995a780759a884191eb59 Mon Sep 17 00:00:00 2001 From: Aly Sewelam Date: Mon, 13 Apr 2026 08:46:13 +0200 Subject: [PATCH] replace closure with auth_header function I AM SO COOL --- src/main.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 90b5cb8..52252a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,13 +9,9 @@ mod client; #[tokio::main] async fn main() -> Result<(), Box> { let channel = Channel::from_static("dns:///youtube.googleapis.com:443").connect().await?; - let token: MetadataValue<_> = "Bearer my-secret-token".parse()?; let mut client = V3DataLiveChatMessageServiceClient::with_interceptor( channel, - move |mut req: Request<()>| { - req.metadata_mut().insert("authorization", token.clone()); - Ok(req) - }, + auth_header ); let request = tonic::Request::new(LiveChatMessageListRequest { @@ -36,7 +32,7 @@ async fn main() -> Result<(), Box> { async fn auth_header(mut req: Request<()>) -> Result, InvalidMetadataValue> { - let token: MetadataValue<_> = "Bearer my-secret-token".parse()?; + let token: MetadataValue<_> = "Bearer my-secret-token".parse().expect("failed to parse token"); req.metadata_mut().insert("x-goog-api-key", token).expect("WHAT");