11956a0f83
refactor(resolver,variable): 移除未使用的接口和测试代码
...
- resolver: 移除 StatsCollector 接口和 mockResolver 测试代码
- variable: 移除 Store 接口定义
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 15:56:29 +08:00
a7f01581cb
perf(variable): 全局变量改为惰性加载降低每请求开销
...
之前 NewContext 每次复制所有全局变量到 vc.store,
现在改为 Get() 时按需查找 GetGlobalVariable(),
消除了无关请求的内存复制开销。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-14 14:25:13 +08:00
d21e27fbac
fix(lint): 修复 golangci-lint 错误 (119 -> 0 issues)
...
主要修复:
- errcheck: defer Close 使用 //nolint:errcheck,类型断言改为 ok 检查
- govet fieldalignment: 调整结构体字段顺序优化内存布局
- revive unused-parameter: 将未使用参数改为 _
- exhaustive: 添加缺失的 switch case 或 default
- goconst: 提取重复字符串为常量 (accessAllow, accessDeny 等)
- staticcheck SA9003: 修复空分支逻辑
- gofmt: 运行 gofmt -w 格式化
- nolintlint: 修复 nolint 注释格式
其他改进:
- 更新 .golangci.yml 配置,启用更严格的检查
- 移除未使用的代码和导入
- 简化测试辅助函数调用
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 16:15:31 +08:00
95b6119e34
refactor: 使用标准库 slices/maps 替代自定义函数
...
- 使用 slices.Contains 替代 contains/containsInt 函数
- 使用 maps.Copy 替代手动遍历复制
- 删除 internal/cache 中不再需要的辅助函数
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 13:15:13 +08:00
e9d747a628
refactor(variable): 提取变量展开核心逻辑
...
提取 expandCore 函数作为变量展开的核心实现,
消除 Expand 和 ExpandString 方法中的重复代码。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 10:59:07 +08:00
8b382606df
Merge branch 'lint-fix' - resolve sendfile.go conflict
...
Conflict: sendfile.go (!linux build tag) was incorrectly modified to
include linuxSendfile and getSocketFd functions which already exist
in sendfile_linux.go.
Resolution: Keep HEAD version (simple fallback returning ENOTSUP) as
Linux implementation is properly separated in sendfile_linux.go.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 09:26:48 +08:00
0731dc46e4
refactor(variable): 重命名核心类型移除冗余前缀
...
VariableContext → Context
VariableStore → Store
ReleaseVariableContext → ReleaseContext (别名保留向后兼容)
提取硬编码字符串为命名常量 sslProtocolNone
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 09:40:17 +08:00
668ecde6db
feat(variable): 新增全局变量支持,自动注入请求上下文
2026-04-09 12:18:56 +08:00
61455412eb
feat(variable,proxy): 新增上游变量支持,集成到代理请求处理
...
- 新增 upstream_addr、upstream_status、upstream_response_time 等变量
- 新增 UpstreamTiming 结构体捕获连接、首字节、响应时间
- Proxy.ServeHTTP 集成变量上下文,记录上游时间
- 新增测试覆盖上游变量和计时功能
Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:36:37 +08:00
c95f474539
feat(variable): 新增变量系统支持
...
新增 internal/variable 包,提供 Nginx 风格的变量展开功能:
- 支持 $remote_addr、$host、$uri、$args 等 30+ 内置变量
- 使用 sync.Pool 优化 VariableContext 分配
- 支持 set_response_info 存储响应状态信息
添加 github.com/google/uuid 依赖用于请求 ID 生成。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 11:36:49 +08:00