We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 93c4e43 commit 3d06ec8Copy full SHA for 3d06ec8
1 file changed
examples/middleware-chain/src/main.rs
@@ -124,8 +124,7 @@ impl MiddlewareLayer for CustomAuthMiddleware {
124
// Validate auth header
125
if let Some(auth_header) = req.headers().get("Authorization") {
126
if let Ok(auth_str) = auth_header.to_str() {
127
- if auth_str.starts_with("Bearer ") {
128
- let token = &auth_str[7..];
+ if let Some(token) = auth_str.strip_prefix("Bearer ") {
129
if token == "token123" {
130
println!("✅ Auth successful for {}", path);
131
return next(req).await;
0 commit comments