revert route handle for 3.3.x

This commit is contained in:
wjqserver 2025-05-20 10:03:48 +08:00
parent 146b0d7748
commit d38ca3969f

68
main.go
View file

@ -468,44 +468,52 @@ func main() {
proxy.RoutingHandler(cfg, limiter, iplimiter)(ctx, c) proxy.RoutingHandler(cfg, limiter, iplimiter)(ctx, c)
}) })
r.GET("/v2/", func(ctx context.Context, c *app.RequestContext) { // for 3.4.0
proxy.GhcrRouting(cfg)(ctx, c)
/* /*
//proxy.GhcrRouting(cfg)(ctx, c) r.GET("/v2/", func(ctx context.Context, c *app.RequestContext) {
// 返回200与空json proxy.GhcrRouting(cfg)(ctx, c)
//c.JSON(200, map[string]interface{}{})
emptyJSON := "{}"
//emptyJSON := `{"name":"disable-list-tags","tags":[]}`
c.Header("Content-Type", "application/json")
c.Header("Content-Length", fmt.Sprint(len(emptyJSON)))
c.String(200, emptyJSON)
*/
/*
emptyJSON := "{}"
c.Header("Content-Type", "application/json")
c.Header("Content-Length", fmt.Sprint(len(emptyJSON)))
c.Header("Docker-Distribution-API-Version", "registry/2.0") /*
//proxy.GhcrRouting(cfg)(ctx, c)
// 返回200与空json
//c.JSON(200, map[string]interface{}{})
emptyJSON := "{}"
//emptyJSON := `{"name":"disable-list-tags","tags":[]}`
c.Header("Content-Type", "application/json")
c.Header("Content-Length", fmt.Sprint(len(emptyJSON)))
c.String(200, emptyJSON)
*/
/*
emptyJSON := "{}"
c.Header("Content-Type", "application/json")
c.Header("Content-Length", fmt.Sprint(len(emptyJSON)))
c.Status(200) c.Header("Docker-Distribution-API-Version", "registry/2.0")
c.Write([]byte(emptyJSON))
*/
/* c.Status(200)
w := adaptor.GetCompatResponseWriter(&c.Response) c.Write([]byte(emptyJSON))
*/
const emptyJSON = "{}" /*
w.Header().Set("Content-Type", "application/json") w := adaptor.GetCompatResponseWriter(&c.Response)
w.Header().Set("Content-Length", fmt.Sprint(len(emptyJSON)))
w.Header().Del("Server")
fmt.Fprint(w, emptyJSON) const emptyJSON = "{}"
*/ w.Header().Set("Content-Type", "application/json")
w.Header().Set("Content-Length", fmt.Sprint(len(emptyJSON)))
w.Header().Del("Server")
}) fmt.Fprint(w, emptyJSON)
*/
/*
})
r.Any("/v2/:target/*filepath", func(ctx context.Context, c *app.RequestContext) { r.Any("/v2/:target/*filepath", func(ctx context.Context, c *app.RequestContext) {
proxy.GhcrRouting(cfg)(ctx, c)
})
*/
r.Any("/v2/*filepath", func(ctx context.Context, c *app.RequestContext) {
proxy.GhcrRouting(cfg)(ctx, c) proxy.GhcrRouting(cfg)(ctx, c)
}) })