Help us shape the future of Go! Take the 2026 Go Developer Survey

baseurl

package
v0.32.41 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package baseurl 公开链接 base 解析(请求级公开地址推断的单源)。

语义(2026-10-10 自 app/share 域下沉,此前 presign/gen·handler/chunk·share 四处消费 share.ResolveBase 构成 app 跨域边与适配层对域词汇依赖): 显式配置 > 请求来源(bootstrap 中间件注入 ctx)> 空串。 禁止回退 server.host——那是监听地址(0.0.0.0),拼进分享链接对外不可达 (2026-10-07 iStoreOS 真机事故:分享成功弹窗给出 http://0.0.0.0:12345/#/s/x)。 双缺省时退相对路径(/#/share/CODE),浏览器侧可由 location.origin 补全。

Index

Constants

This section is empty.

Variables

View Source
var PublicBaseCtxKey publicBaseCtxKeyType

PublicBaseCtxKey 请求级公开 base 在 go ctx 中的键。bootstrap 在 server.base_url 未配置时挂中间件,把每条请求的来源(scheme://host) 经 context.WithValue 包进 go ctx 并 c.Next 透传——域服务读的是 handler 首参 go ctx;c.Set 只落 RequestContext.Keys,service 层读不到(曾致推断死代码)。

Functions

func Resolve

func Resolve(ctx context.Context, configured string) string

Resolve 公开链接 base 解析:显式配置 > 请求来源(中间件注入)> 空串。

func ShareDownloadURL added in v0.28.0

func ShareDownloadURL(base, code, token string) string

ShareDownloadURL 拼「带下载令牌的直链」:{base}/share/download?code={code}[&token={token}]。

与 SharePageURL 的分工:这里的令牌要**由服务端校验**,所以必须是 query 形态(落在 '#' 之后服务端就收不到,2026-10-22 修复时的关键约束)。 与取件详情响应下发的 url 字段同构(core 取件链路已用该形态)。

func SharePageURL added in v0.28.0

func SharePageURL(base, code string) string

SharePageURL 拼「用户可点击的取件页」地址:{base}/#/share/{code}。

base 为空(未配置 base_url 且请求来源不可推断)时退相对形态 "/#/share/{code}",由浏览器端按 location.origin 补全。

func SplitSharePageURL added in v0.28.0

func SplitSharePageURL(pageURL, code string) (base string)

SplitSharePageURL 从页面链接里拆出 base 与分享码。

用途:由服务端下发的分享链接派生直链(base + /share/download?code=…)。

形态:**只有** {base}/#/share/{code}(hash 路由)——服务端自产的链接一律是它 (SharePageURL 的唯一产物;MCP 与 presign complete 的两个调用方传的都是 服务端自产 URL)⇒ 旧形态 {base}/share/{code} 分支**不可达**,已移除。

base 为空(相对形态)时返回空 base,调用方拼出相对直链。

Types

This section is empty.

Jump to

Keyboard shortcuts

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