Skip to main content

build_router_with_auth

Function build_router_with_auth 

Source
pub fn build_router_with_auth(state: AppState, auth: AuthConfig) -> Router
Expand description

Build the HTTP router with an explicit AuthConfig.

Tests use this to inject a known auth state without touching process-global env vars. Production code paths use build_router.

The rate limiter is taken from AppState.rate_limiter. Callers should populate it via rate_limiter_from_env for production or with RateLimiter::new for deterministic tests. Tests that need race-free rate-limit assertions should use build_router_with_auth_and_rate_limit instead.