Documentation
¶
Overview ¶
Package httpapi 提供中转的 HTTP 面(执行计划 §6.8):仅 health/config (config 通告支持的线协议版本与限额,供客户端预检,§6.7)与 WS Origin 白名单。不设 HTTP 清单端点——清单只经 WS join 获取;静态前端由站点/CDN 托管,与中转分离。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
NewHandler 组装中转的全部 HTTP 面:health/config 与 WS 升级入口。 不含静态托管——前端由站点/CDN 分离部署(§6.8),同域需求交给反向代理。
func ValidateConfig ¶
ValidateConfig fails malformed deployment policy before the listener starts. An invalid allowlist must never degrade into a running deny-all server.
func WithConnectionLease ¶
WithConnectionLease transfers a listener-admitted TCP lease to the request handler. The production server uses it to cover slow headers and keep-alives; standalone handlers fall back to admission immediately before upgrade.
Types ¶
type Config ¶
type Config struct {
Hub *signaling.Hub
// AllowedOrigins:允许发起 WS 的浏览器 Origin 白名单(完整 origin,如
// https://windshare.top),由部署方配置(§6.8);自部署中转可放行自部署
// 前端。大小写不敏感。
AllowedOrigins []string
// AllowLocalhost:dev 放行任意 localhost/127.0.0.1/[::1] 来源(§6.8)。
AllowLocalhost bool
// Limits 经 /v1/config 通告,供客户端预检(§6.7)。须与 hub 的执行值
// 一致——通告与执行不一致比不通告更糟。
Limits protocol.ServerLimits
// SourceIdentity derives the admission identity from the request. Production
// defaults to the TCP peer and deliberately ignores spoofable forwarding
// headers; trusted-proxy deployments can inject their own verified policy.
SourceIdentity func(*http.Request) string
}
Config 配置 HTTP/策略面。限额通告若留零值,取与 hub 一致的默认。