Skip to main content

build_router

Function build_router 

Source
pub fn build_router(state: Arc<AppState>) -> Router
Expand description

Build the axum Router with all routes and middleware applied.

Reads AuthConfig ($TENSOR_WASM_API_TOKENS), TenantConfig ($TENSOR_WASM_API_REQUIRE_TENANT), RateLimitConfig ($TENSOR_WASM_API_RATE_LIMIT_QPS / $TENSOR_WASM_API_RATE_LIMIT_BURST), and CorsConfig ($TENSOR_WASM_API_CORS_ALLOWED_ORIGINS) from the process environment. Empty / unset TENSOR_WASM_API_TOKENS puts the gateway in dev mode (auth disabled with a startup warning); unset or zero rate-limit knobs disable the limiter (pass-through); empty / unset CORS allowlist rejects every cross-origin request (safe default).

If any bare (unscoped) entries are present in TENSOR_WASM_API_TOKENS, AuthConfig::from_env emits a one-shot deprecation warning naming the count — scoped tokens (token:tenant=...) are the supported form going forward and bare entries are scheduled for removal in v1.0.