Documentation
¶
Overview ¶
Package pathproxy 路径代理模块:把 /api/pathproxy/<path> 的请求按配置 规则转发到对应上游 URL,支持精确路径与末尾 "*" 通配。
规则在 modules.pathproxy.path_rules 中配置:
- path: "/api1/users" target: "https://api.example.com/users" allowed_referers:
- "localhost:4000" headers: Authentication: "Bearer your-token"
- path: "/api2/*" target: "https://api.example.com/" allowed_referers:
- "localhost:5000"
path 为模块前缀 /api/pathproxy 之后的路径;末尾 "*" 表示通配其后任意 路径,命中后把通配部分拼接在 target 的路径之后。请求方法、查询参数与 请求体原样转发;headers 中的配置会设置/覆盖到上游请求。每条规则通过 自己的 allowed_referers 校验来源。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct{}
Controller 路径代理模块控制器。
func (*Controller) Register ¶
func (c *Controller) Register(r *gin.RouterGroup)
Register 注册路由:/api/pathproxy/*proxyPath,支持任意 HTTP 方法。