This commit is contained in:
wjqserver 2025-06-18 09:05:45 +08:00
parent e629b5db47
commit 933aeee518
6 changed files with 21 additions and 19 deletions

21
main.go
View file

@ -414,16 +414,21 @@ func main() {
proxy.RoutingHandler(cfg)(c)
})
r.GET("/v2/", r.UseIf(cfg.Docker.Auth, bauth.BasicAuthForStatic(cfg.Docker.Credentials, "GHProxy Docker Proxy")), func(c *touka.Context) {
emptyJSON := "{}"
c.Header("Content-Type", "application/json")
c.Header("Content-Length", fmt.Sprint(len(emptyJSON)))
r.GET("/v2/",
r.UseIf(cfg.Docker.Auth, func() touka.HandlerFunc {
return bauth.BasicAuthForStatic(cfg.Docker.Credentials, "GHProxy Docker Proxy")
}),
func(c *touka.Context) {
emptyJSON := "{}"
c.Header("Content-Type", "application/json")
c.Header("Content-Length", fmt.Sprint(len(emptyJSON)))
c.Header("Docker-Distribution-API-Version", "registry/2.0")
c.Header("Docker-Distribution-API-Version", "registry/2.0")
c.Status(200)
c.Writer.Write([]byte(emptyJSON))
})
c.Status(200)
c.Writer.Write([]byte(emptyJSON))
},
)
r.GET("/v2", func(c *touka.Context) {
// 重定向到 /v2/