httpapi

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func NewHandler(cfg Config) http.Handler

NewHandler 组装中转的全部 HTTP 面:health/config 与 WS 升级入口。 不含静态托管——前端由站点/CDN 分离部署(§6.8),同域需求交给反向代理。

func ValidateConfig

func ValidateConfig(cfg Config) error

ValidateConfig fails malformed deployment policy before the listener starts. An invalid allowlist must never degrade into a running deny-all server.

func WithConnectionLease

func WithConnectionLease(ctx context.Context, lease *signaling.ConnectionLease) context.Context

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 一致的默认。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL