Skip to content

Commit 3d06ec8

Browse files
committed
Update main.rs
1 parent 93c4e43 commit 3d06ec8

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

  • examples/middleware-chain/src

examples/middleware-chain/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ impl MiddlewareLayer for CustomAuthMiddleware {
124124
// Validate auth header
125125
if let Some(auth_header) = req.headers().get("Authorization") {
126126
if let Ok(auth_str) = auth_header.to_str() {
127-
if auth_str.starts_with("Bearer ") {
128-
let token = &auth_str[7..];
127+
if let Some(token) = auth_str.strip_prefix("Bearer ") {
129128
if token == "token123" {
130129
println!("✅ Auth successful for {}", path);
131130
return next(req).await;

0 commit comments

Comments
 (0)