# `createScalarUiHandler` — Scalar HTTP handler factory _(no submodules)_ ## Purpose The handler module owns the public `createScalarUiHandler` factory the host calls when `host.openapi.ui = "scalar"`. It validates the caller-supplied options through the Zod schema, eagerly resolves the Scalar runtime asset URL (CDN or bundled), constructs the OTel instrument bundle, and returns a frozen `ScalarUiHandlerBundle` whose `handler` field is the actual HTTP handler callable. The bundle also exposes an `assetHandler` for the bundled-mode `/assets/` sub-route the host mounts alongside the main shell. ## Features - Eager validation — invalid options or missing bundled assets fail at handler construction rather than at first request. - Strict CSP — `Content-Security-Policy` header value is derived once at construction time so request handling never has to recompute it. The policy widens to whitelist the CDN origin only when `assetMode = "cdn"`. - Per-request CSP nonce passthrough — the handler accepts an optional `nonce` on each request which the renderer threads onto the inline `