Compare commits

..

2 Commits

Author SHA1 Message Date
dependabot[bot]
55a287f93a
chore(deps): bump golang.org/x/net from 0.40.0 to 0.41.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.40.0 to 0.41.0.
- [Commits](https://github.com/golang/net/compare/v0.40.0...v0.41.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.41.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-22 04:54:48 +00:00
c04f600332 添加favicon支持,更新docker-compose配置以挂载favicon目录,并在主程序中实现favicon.ico处理器,提供自定义favicon功能。 2025-06-22 12:53:27 +08:00
5 changed files with 56 additions and 2 deletions

View File

@ -6,6 +6,7 @@ services:
- "3336:3336"
volumes:
- ./data:/app/data
- ./favicon:/app/favicon
environment:
- TZ=Asia/Shanghai
- OAUTH_CLIENT_ID=your_client_id

2
favicon/.gitkeep Normal file
View File

@ -0,0 +1,2 @@
# 这个文件确保 favicon 目录被 git 跟踪
# 用户可以在这个目录中放置自定义的 favicon.ico 文件

32
favicon/README.md Normal file
View File

@ -0,0 +1,32 @@
# Favicon 自定义设置
## 使用方法
1. 将你的 favicon 文件重命名为 `favicon.ico`
2. 放置在这个 `favicon` 目录中
3. 重启 proxy-go 服务
## 支持的文件格式
- `.ico` 文件(推荐)
- `.png` 文件(需要重命名为 favicon.ico
- `.jpg/.jpeg` 文件(需要重命名为 favicon.ico
- `.svg` 文件(需要重命名为 favicon.ico
## 注意事项
- 文件必须命名为 `favicon.ico`
- 推荐尺寸16x16, 32x32, 48x48 像素
- 如果没有放置文件,将返回 404浏览器会使用默认图标
## 示例
```bash
# 将你的 favicon 文件复制到这个目录
cp your-favicon.ico ./favicon/favicon.ico
# 重启服务
docker-compose restart
```
现在访问 `http://your-domain.com/favicon.ico` 就会显示你的自定义 favicon 了!

4
go.mod
View File

@ -1,8 +1,8 @@
module proxy-go
go 1.24
go 1.23.0
toolchain go1.24.4
toolchain go1.23.1
require (
github.com/andybalholm/brotli v1.1.1

19
main.go
View File

@ -129,6 +129,25 @@ func main() {
matcher func(*http.Request) bool
handler http.Handler
}{
// favicon.ico 处理器
{
matcher: func(r *http.Request) bool {
return r.URL.Path == "/favicon.ico"
},
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// 检查是否有自定义favicon文件
faviconPath := "favicon/favicon.ico"
if _, err := os.Stat(faviconPath); err == nil {
// 设置正确的Content-Type和缓存头
w.Header().Set("Content-Type", "image/x-icon")
w.Header().Set("Cache-Control", "public, max-age=31536000") // 1年缓存
http.ServeFile(w, r, faviconPath)
} else {
// 如果没有自定义favicon返回404
http.NotFound(w, r)
}
}),
},
// 管理路由处理器
{
matcher: func(r *http.Request) bool {