Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Can not flush cache

未关闭
#140 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
go
领域
api, backend

调研方向

从 pkg/api/souin.go:316 开始,这里向 /souin-api/souin/flush 发起 PURGE 请求时会发生 panic,并将其与 Caddyfile 缓存 API 配置进行比较。使用提供的 curl 命令重现该请求,并检查相关的 API handler 路径。当端点返回响应且不发生 nil-pointer panic,并按预期刷新缓存时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

caddy version: 1.11.2

$ curl -v -X PURGE http://localhost:2019/souin-api/souin/flush
* Host localhost:2019 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:2019...
* Connected to localhost (::1) port 2019
* using HTTP/1.x
> PURGE /souin-api/souin/flush HTTP/1.1
> Host: localhost:2019
> User-Agent: curl/8.14.1
> Accept: */*
> 
* Request completely sent off
* Empty reply from server
* shutting down connection #0
curl: (52) Empty reply from server

log

{"level":"info","ts":1773995888.740839,"logger":"admin.api","msg":"received request","method":"PURGE","host":"localhost:2019","uri":"/souin-api/souin/flush","remote_ip":"10.88.0.112","remote_port":"54338","headers":{"Accept":["*/*"],"User-Agent":["curl/8.14.1"]}}
{"level":"info","ts":1773995888.7425144,"msg":"http: panic serving 10.88.0.112:54338: runtime error: invalid memory address or nil pointer dereference\ngoroutine 2663 [running]:\nnet/http.(*conn).serve.func1()\n\tnet/http/server.go:1907 +0xbd\npanic({0x1c7bd00?, 0x37542c0?})\n\truntime/panic.go:860 +0x13a\ngithub.com/darkweak/souin/pkg/api.(*SouinAPI).HandleRequest(0x2514e81b5020, {0x23581f0, 0x2514e9083110}, 0x2514e8130140)\n\tgithub.com/darkweak/[email protected]/pkg/api/souin.go:316 +0x931\ngithub.com/caddyserver/cache-handler.(*adminAPI).handleAPIEndpoints(0x2514e8643050?, {0x23581f0, 0x2514e9083110}, 0x2514e8130140)\n\tgithub.com/caddyserver/[email protected]/admin.go:41 +0xf2\ngithub.com/caddyserver/caddy/v2.AdminHandlerFunc.ServeHTTP(0x425234?, {0x23581f0?, 0x2514e9083110?}, 0x2514e925aab0?)\n\tgithub.com/caddyserver/caddy/[email protected]/admin.go:1360 +0x29\ngithub.com/caddyserver/caddy/v2.(*AdminConfig).newAdminHandler.(*AdminConfig).newAdminHandler.func2.func6({0x23581f0, 0x2514e9083110}, 0x2514e8130140)\n\tgithub.com/caddyserver/caddy/[email protected]/admin.go:248 +0x7b\nnet/http.HandlerFunc.ServeHTTP(0x2358580?, {0x23581f0?, 0x2514e9083110?}, 0x2514e860b750?)\n\tnet/http/server.go:2286 +0x29\ngithub.com/caddyserver/caddy/v2.(*AdminConfig).newAdminHandler.func1.instrumentHandlerCounter.1({0x2358580?, 0x2514e82fe5a0?}, 0x2514e8130140)\n\tgithub.com/caddyserver/caddy/[email protected]/metrics.go:56 +0x6f\nnet/http.HandlerFunc.ServeHTTP(0x2514e927e3c0?, {0x2358580?, 0x2514e82fe5a0?}, 0x74c47f?)\n\tnet/http/server.go:2286 +0x29\nnet/http.(*ServeMux).ServeHTTP(0x2514e8640f90?, {0x2358580, 0x2514e82fe5a0}, 0x2514e8130140)\n\tnet/http/server.go:2828 +0x1c7\ngithub.com/caddyserver/caddy/v2.adminHandler.serveHTTP({0x2514e927e3c0, 0x0, 0x0, {0x2514e7e86528, 0x1, 0x1}, 0x0}, {0x2358580, 0x2514e82fe5a0}, 0x2514e8130140)\n\tgithub.com/caddyserver/caddy/[email protected]/admin.go:891 +0x793\ngithub.com/caddyserver/caddy/v2.adminHandler.ServeHTTP({0x2514e927e3c0, 0x0, 0x0, {0x2514e7e86528, 0x1, 0x1}, 0x0}, {0x2358580, 0x2514e82fe5a0}, 0x2514e8130140)\n\tgithub.com/caddyserver/caddy/[email protected]/admin.go:816 +0x7a5\nnet/http.serverHandler.ServeHTTP({0x2514e829d180?}, {0x2358580?, 0x2514e82fe5a0?}, 0x1?)\n\tnet/http/server.go:3311 +0x8e\nnet/http.(*conn).serve(0x2514e925aa20, {0x235da70, 0x2514e85e1380})\n\tnet/http/server.go:2073 +0x650\ncreated by net/http.(*Server).Serve in goroutine 2372\n\tnet/http/server.go:3464 +0x485"}

Caddyfile

{
	debug
	order cache before rewrite

	cache {
		api {
			souin
		}
	}
}

example.com {
    @cacheable {
        not path /
    }
    handle @cacheable {
        cache {
            ttl 120s
        }
    }

    file_server
}
主要语言
Go
星标
396
派生
29
平均合并
32 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

caddyserver/cache-handler 的其他 Issue

查看 caddyserver/cache-handler 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。