perf: OnceLock for env var, Arc<CurrentUser> in auth, pre-compute query lowercase
- rate_limit: cache OXICLOUD_TRUST_PROXY_HEADERS in OnceLock<bool> to avoid syscall on every request (~500ns → ~1ns) - auth middleware: insert Arc<CurrentUser> instead of bare CurrentUser; all 5 extractors now clone Arc (~1ns) instead of 4 Strings (~60-100ns) - search_service: pre-compute query.to_lowercase() once before loops, eliminating N redundant heap allocations per search
This commit is contained in:
@@ -128,8 +128,8 @@ fn reject_path_traversal(path: &str) -> Result<(), AppError> {
|
||||
|
||||
fn extract_user(req: &Request<Body>) -> Result<CurrentUser, AppError> {
|
||||
req.extensions()
|
||||
.get::<CurrentUser>()
|
||||
.cloned()
|
||||
.get::<Arc<CurrentUser>>()
|
||||
.map(|arc| (**arc).clone())
|
||||
.ok_or_else(|| AppError::unauthorized("Authentication required"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user