NPRPC docs

typealias PageHandler

Swift

typealias PageHandler = @Sendable (PageRequest) -> PageResponse?

Renders a page, or returns nil to decline the request.

Declining falls through to the static file cache, so returning nil for paths you do not recognise is how assets keep their zero-copy path.

Called synchronously on an HTTP I/O thread, and on several concurrently when the server runs a thread pool, hence @Sendable. A render that blocks holds up an I/O thread, so anything slow (a database round-trip, a network call) belongs elsewhere, with the handler serving what it already has.

nprpc_swift/Sources/NPRPC/PageHandler.swift:117