class RpcBuilderHttp
Swift
final class RpcBuilderHttp
HTTP/WebSocket-specific builder with SSL and page-rendering options
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:241
Methods
@discardableResult func allowOrigins(_ origins: [String]) -> RpcBuilderHttp
Allow browser cross-origin requests from the provided HTTPS origins.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:306
@discardableResult func enableHttp3() -> RpcBuilderHttp
Enable HTTP/3 support
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:273
@discardableResult func enableWebSocketCompression(_ enabled: Bool = true) -> RpcBuilderHttp
Enable or disable WebSocket permessage-deflate negotiation.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:320
@discardableResult func http3ShmChannels(egress egressChannel: String, ingress ingressChannel: String) -> RpcBuilderHttp
Configure shared memory channels for npquicrouter integration.
egressChannel- Matches "http3_shm_channel" in npquicrouter's config.json.
ingressChannel- Matches the route's "shm_channel" in npquicrouter's config.json.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:431
@discardableResult func http3Workers(_ count: UInt) -> RpcBuilderHttp
Set the number of dedicated HTTP/3 worker sockets/threads. Pass 0 to auto-size from hardware concurrency; default: 4.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:342
@discardableResult func maxHttp3ConnectionsPerIp(_ count: UInt) -> RpcBuilderHttp
Cap concurrently active HTTP/3 connections per client IP.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:372
@discardableResult func maxHttp3NewConnectionsPerIpPerSecond(_ rate: UInt, burst: UInt = 0) -> RpcBuilderHttp
Limit new HTTP/3 connection attempts per client IP.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:379
@discardableResult func maxHttpRpcRequestsPerIpPerSecond(_ rate: UInt, burst: UInt = 0) -> RpcBuilderHttp
Limit HTTP RPC requests per client IP across HTTP/1.1 and HTTP/3.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:387
@discardableResult func maxRequestBodySize(_ bytes: UInt) -> RpcBuilderHttp
Cap buffered HTTP request bodies before dispatch.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:313
@discardableResult func maxWebSocketMessageSize(_ bytes: UInt) -> RpcBuilderHttp
Cap inbound WebSocket message size.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:327
@discardableResult func maxWebSocketRequestsPerSessionPerSecond(_ rate: UInt, burst: UInt = 0) -> RpcBuilderHttp
Limit request messages received on a single WebSocket session.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:364
@discardableResult func maxWebSocketSessionsPerIp(_ count: UInt) -> RpcBuilderHttp
Cap concurrently active WebSocket sessions per client IP.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:349
@discardableResult func maxWebSocketUpgradesPerIpPerSecond(_ rate: UInt, burst: UInt = 0) -> RpcBuilderHttp
Limit WebSocket upgrade attempts per client IP.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:356
@discardableResult func maxWebTransportConnectsPerIpPerSecond(_ rate: UInt, burst: UInt = 0) -> RpcBuilderHttp
Limit WebTransport CONNECT requests per client IP.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:395
@discardableResult func maxWebTransportMessageSize(_ bytes: UInt) -> RpcBuilderHttp
Cap inbound WebTransport control/native payload size.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:334
@discardableResult func maxWebTransportRequestsPerSessionPerSecond(_ rate: UInt, burst: UInt = 0) -> RpcBuilderHttp
Limit WebTransport framed requests per session.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:403
@discardableResult func maxWebTransportStreamOpensPerSessionPerSecond(_ rate: UInt, burst: UInt = 0) -> RpcBuilderHttp
Limit WebTransport child stream opens per session.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:411
@discardableResult func rootDir(_ path: String) -> RpcBuilderHttp
Set HTTP document root directory
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:299
@discardableResult func ssl(certFile: String, keyFile: String, dhparamsFile: String = "") -> RpcBuilderHttp
Enable SSL/TLS for HTTP and WebSocket
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:250
@discardableResult func watchCertificates(intervalSeconds interval: UInt32) -> RpcBuilderHttp
Poll the certificate and key files and reload them in-process when
either changes on disk, so a certbot renewal is picked up without a
restart. Zero (the default) disables polling; the certificate can
still be reloaded on demand with Rpc.reloadCertificates(), which is
the better fit when certbot can run a deploy hook.
interval- seconds between checks
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:266
@discardableResult func watchFiles() -> RpcBuilderHttp
Enable inotify-based cache invalidation on the HTTP root directory. Any file written or renamed under rootDir() is immediately evicted from the file cache so the next request reloads it from disk. Useful during development — no effect on non-Linux platforms.
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:422
@discardableResult func withPageHandler(_ handler: @escaping PageHandler) -> RpcBuilderHttp
Render pages in this process.
handler is consulted for every GET/HEAD/POST the RPC endpoint did not
claim. Returning nil falls through to static file serving, so assets
keep their zero-copy path.
.withPageHandler { request in
guard request.path == "/blog" else { return nil }
let page = Int(request.queryItems["page"] ?? "1") ?? 1
return PageResponse(html: renderBlog(page))
}
nprpc_swift/Sources/NPRPC/RpcBuilder.swift:292