11 Commits

Author SHA1 Message Date
xfy
93e3ee0b14 feat(handler,compression): 使用 mimeutil 统一 Content-Type 检测
- 替换 mime.TypeByExtension 为 mimeutil.DetectContentType
- 为 sendfile 大文件路径添加 Content-Type 设置
- 为预压缩文件添加原始 Content-Type
- 添加大文件 Content-Type 测试验证

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 16:55:37 +08:00
xfy
4e826925ac refactor: 适配核心模块类型重命名
适配 variable.NewContext/ReleaseContext
适配 resolver.DNSCacheEntry
适配 logging/formatJSON 常量

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 09:41:07 +08:00
xfy
84d67c8570 feat(handler/static): 新增 alias 指令支持路径别名
- NewStaticHandlerWithAlias 创建带 alias 的静态文件处理器
- alias 与 root 互斥,支持路径替换而非附加
- 新增测试覆盖 alias 路径映射逻辑

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:37:20 +08:00
xfy
b72394eb3b style(handler,server): 格式化测试代码结构体字段对齐
- 对齐 errorpage_test.go、static_test.go、pprof_test.go 中的结构体字段
- 纯代码格式化,无逻辑变更

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 13:30:00 +08:00
xfy
b6f8894d78 test(handler,middleware,server): 新增 try_files、错误页面、pprof 单元测试
- static_test.go: 新增 try_files 配置解析、占位符解析、SPA 场景测试
- errorpage_test.go: 新增错误页面管理器完整测试覆盖
- errorintercept_test.go: 新增错误拦截中间件功能测试
- pprof_test.go: 新增 pprof 性能分析端点测试

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 11:15:39 +08:00
xfy
83e1fe38ba feat(config,handler,server): 支持多静态目录配置,新增路径前缀匹配
- Static 配置从单对象改为数组,支持多个静态目录
- StaticConfig 新增 Path 字段用于路径前缀匹配
- 添加 validateStatics 和 validatePathConflicts 验证函数
- 删除 config.example.yaml 示例文件(配置可通过 --generate 生成)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 16:26:55 +08:00
xfy
f2352ab9cc docs(config,stream,logging,handler,proxy,cache,server,ssl,middleware): 为核心模块添加详细 GoDoc 文档注释
- config: 为 Config 和所有子配置结构添加完整文档,包含使用示例和注意事项
- stream: 为负载均衡器和服务器添加详细的参数、返回值和功能说明
- logging: 为日志格式化和输出函数添加文档,说明支持的变量替换
- handler: 为路由器、静态文件和 sendfile 处理器添加文档
- proxy: 为健康检查器和代理功能添加完整文档
- cache/server/ssl/middleware: 补充相关模块的文档注释
- config.example.yaml: 添加可信代理配置、加密套件示例,更新压缩级别说明

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 15:36:09 +08:00
xfy
0a50678b55 test(handler): 完善 handler 模块测试覆盖率
覆盖率从 45.3% 提升至 58.5%,新增测试:
- TestStaticHandler_SetFileCache: 文件缓存设置测试
- TestStaticHandler_SetGzipStatic: Gzip 静态文件设置测试
- TestStaticHandler_Handle_HeadRequest: HEAD 请求测试
- TestStaticHandler_Handle_WithCache: 带缓存处理测试
- TestStaticHandler_Handle_Precompressed: 预压缩文件测试
- TestStaticHandler_Handle_LargeFile: 大文件处理测试
- TestStaticHandler_Handle_Symlink: 符号链接测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 18:35:39 +08:00
xfy
aa64329ba2 feat(server,handler,proxy,app): 集成未使用的中间件和模块
- 集成 6 个安全/功能中间件到 server.go
- 集成 GoroutinePool 和 SendFile 零拷贝
- 集成 FileCache 和 ProxyCache 缓存模块
- 集成 Stream TCP/UDP 代理模块
- 添加 Stream 配置结构到 config.go

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 11:27:53 +08:00
xfy
9d24263918 feat(stream,server,handler): 实现 Phase 6 性能优化和热升级
新增功能:
- stream 模块: 流式传输支持,优化大文件和实时数据传输
- Goroutine 池: 限制并发数量,减少调度开销
- 优雅升级: 零停机热升级,继承父进程监听器
- sendfile: 零拷贝文件传输,大文件直接从内核传输

重构改进:
- App 结构体封装,支持热升级和信号处理
- 配置结构字段对齐和代码清理
- 完善错误处理和日志记录

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-03 10:39:22 +08:00
xfy
413e418b37 test: 添加 handler/logging/middleware/server 模块单元测试
- internal/handler/static_test.go: 21 个测试用例覆盖静态文件服务和路径遍历安全
- internal/handler/router_test.go: 9 个测试用例覆盖路由注册和方法区分
- internal/logging/logging_test.go: 7 个测试用例覆盖日志级别解析
- internal/middleware/middleware_test.go: 4 个测试用例覆盖中间件链逆序包装
- internal/server/server_test.go: 5 个测试用例覆盖服务器创建和停止
- internal/server/vhost_test.go: 18 个测试用例覆盖虚拟主机路由

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 16:21:49 +08:00