* feat(codex): support custom base URL * fix(codex): require HTTPS for custom base URL * docs: document changed subscription functions * fix(groups): 展示并区分详情中的默认与自定义地址 * fix(groups): 统一上游地址配置交互与图标位置 * fix(subscription): 绑定额度重置操作的上游地址 * fix(gateway): 隔离旧上游请求的健康状态更新 --------- Co-authored-by: tbphp <tangb7420@gmail.com>
28 lines
633 B
Go
28 lines
633 B
Go
package subscriptionruntime
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"gpt-load/internal/channel/spec"
|
|
)
|
|
|
|
// BaseURL 返回可选的订阅 API 代理根地址;空值保留官方端点集合。
|
|
func (target Target) BaseURL() (string, error) {
|
|
if len(bytes.TrimSpace(target.Config)) == 0 {
|
|
return "", nil
|
|
}
|
|
var config struct {
|
|
BaseURL string `json:"base_url"`
|
|
}
|
|
if err := json.Unmarshal(target.Config, &config); err != nil {
|
|
return "", fmt.Errorf("decode subscription target: %w", err)
|
|
}
|
|
if strings.TrimSpace(config.BaseURL) == "" {
|
|
return "", nil
|
|
}
|
|
return spec.NormalizeHTTPSBaseURL(config.BaseURL)
|
|
}
|