Performance improvement. String removal from hot paths.

This commit is contained in:
Ara Sadoyan
2026-01-27 16:19:51 +01:00
parent 38055ae94e
commit 2b437c65fb
9 changed files with 461 additions and 358 deletions

View File

@@ -3,6 +3,7 @@ use base64::engine::general_purpose::STANDARD;
use base64::Engine;
use pingora_proxy::Session;
use std::collections::HashMap;
use std::sync::Arc;
use urlencoding::decode;
trait AuthValidator {
@@ -56,18 +57,18 @@ fn validate(auth: &dyn AuthValidator, session: &Session) -> bool {
auth.validate(session)
}
pub fn authenticate(c: &[String], session: &Session) -> bool {
match c[0].as_str() {
pub fn authenticate(c: &[Arc<str>], session: &Session) -> bool {
match &*c[0] {
"basic" => {
let auth = BasicAuth(c[1].as_str().into());
let auth = BasicAuth(&*c[1]);
validate(&auth, session)
}
"apikey" => {
let auth = ApiKeyAuth(c[1].as_str().into());
let auth = ApiKeyAuth(&*c[1]);
validate(&auth, session)
}
"jwt" => {
let auth = JwtAuth(c[1].as_str().into());
let auth = JwtAuth(&*c[1]);
validate(&auth, session)
}
_ => {