lolly/AGENTS.md
xfy 53ac4c84cd docs(AGENTS.md): fix stale references
Remove non-existent config.example.yaml and .github/ directory
references. Add --generate-config usage note.
2026-06-03 10:16:29 +08:00

60 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- Generated: 2026-04-02 | Updated: 2026-04-24 -->
# lolly
## Purpose
高性能 HTTP 服务器,类似 nginx 的纯 Go 实现。使用 YAML 配置单二进制运行支持静态文件服务、反向代理、负载均衡、SSL/TLS、安全控制等功能。
## Key Files
| File | Description |
|------|-------------|
| `main.go` | 程序入口CLI 参数解析和启动逻辑 |
| `go.mod` | Go 模块定义,依赖 fasthttp、zerolog、yaml.v3 |
| `go.sum` | 依赖版本锁定 |
| `Makefile` | 构建脚本,支持多平台编译、测试、覆盖率 |
| `lolly.yaml` | 默认配置文件示例 |
| `.gitignore` | Git 忽略规则 |
## Subdirectories
| Directory | Purpose |
|-----------|---------|
| `internal/` | 核心业务代码(不可被外部导入) |
| `bin/` | 编译输出目录 |
| `docs/` | 项目文档和实现计划 |
| `examples/` | Lua 脚本示例 |
| `html/` | 静态 HTML 文件(测试/示例) |
| `scripts/` | 构建/测试辅助脚本(回归检测) |
## For AI Agents
### Working In This Directory
- 这是 Go 项目,使用 `go mod` 管理依赖
- 使用 `make build` 构建二进制文件到 `bin/` 目录
- 使用 `make test` 运行测试,`make test-cover` 生成覆盖率报告
- 配置文件使用 YAML 格式,结构定义在 `internal/config/config.go`
- HTTP 库使用 fasthttp比 net/http 快 6 倍),路由使用 fasthttp/router
- 日志库使用 zerolog零分配JSON 输出)
### Testing Requirements
- 运行测试前确保依赖已下载:`go mod download`
- 测试覆盖率目标 >80%
- 使用 `make check` 运行完整检查fmt + lint + test
- 使用 `lolly --generate-config` 生成完整配置文件模板
### Common Patterns
- 配置结构体使用 `yaml` 标签,通过 `gopkg.in/yaml.v3` 解析
- 中间件使用 `fasthttp.RequestHandler` 函数签名
- 版本信息通过 `-ldflags` 在编译时注入
- 信号处理SIGTERM/SIGINT 快速停止SIGQUIT 优雅停止
## Dependencies
### External
- `github.com/valyala/fasthttp` - 高性能 HTTP 服务器
- `github.com/fasthttp/router` - 基于 radix tree 的路由器
- `github.com/rs/zerolog` - 零分配 JSON 日志库
- `gopkg.in/yaml.v3` - YAML 解析库
<!-- MANUAL: -->