This commit is contained in:
wjqserver 2025-08-11 18:28:03 +08:00
parent 8dca51b897
commit d389a61f09
10 changed files with 273 additions and 155 deletions

17
main.go
View file

@ -474,20 +474,11 @@ func main() {
proxy.RoutingHandler(cfg)(c)
})
r.GET("/v2/",
r.ANY("/v2/*path",
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.Status(200)
c.Writer.Write([]byte(emptyJSON))
},
proxy.OciWithImageRouting(cfg),
)
r.GET("/v2", func(c *touka.Context) {
@ -495,10 +486,6 @@ func main() {
c.Redirect(http.StatusMovedPermanently, "/v2/")
})
r.ANY("/v2/:target/:user/:repo/*filepath", func(c *touka.Context) {
proxy.GhcrWithImageRouting(cfg)(c)
})
r.NoRoute(func(c *touka.Context) {
proxy.NoRouteHandler(cfg)(c)
})