File tree 3 files changed +15
-4
lines changed 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,9 @@ func reqPackageAccess(accessMode perm.AccessMode) func(ctx *context.Context) {
40
40
}
41
41
}
42
42
43
- func Routes (ctx gocontext.Context ) * web.Route {
43
+ // CommonRoutes provide endpoints for most package managers (excepting docker HUB - see below)
44
+ // These are mounted on `/api/packages` (not `/api/v1/packages`)
45
+ func CommonRoutes (ctx gocontext.Context ) * web.Route {
44
46
r := web .NewRoute ()
45
47
46
48
r .Use (context .PackageContexter (ctx ))
@@ -301,7 +303,9 @@ func Routes(ctx gocontext.Context) *web.Route {
301
303
return r
302
304
}
303
305
304
- func ContainerRoutes (ctx gocontext.Context ) * web.Route {
306
+ // DockerContainerRoutes provides endpoints that match the Docker HUB API in order for facilitate downloading packages a docker packages
307
+ // These have to be mounted on `/v2/...` due to compatibility with the Docker HUB API
308
+ func DockerContainerRoutes (ctx gocontext.Context ) * web.Route {
305
309
r := web .NewRoute ()
306
310
307
311
r .Use (context .PackageContexter (ctx ))
Original file line number Diff line number Diff line change @@ -1073,6 +1073,7 @@ func Routes(ctx gocontext.Context) *web.Route {
1073
1073
}, repoAssignment ())
1074
1074
})
1075
1075
1076
+ // NOTE: these are Gitea package management API - see packages.CommonRoutes and packages.DockerContainerRoutes for endpoints to see implementations of package manager APIs
1076
1077
m .Group ("/packages/{username}" , func () {
1077
1078
m .Group ("/{type}/{name}/{version}" , func () {
1078
1079
m .Get ("" , packages .GetPackage )
Original file line number Diff line number Diff line change @@ -185,9 +185,15 @@ func NormalRoutes(ctx context.Context) *web.Route {
185
185
r .Mount ("/" , web_routers .Routes (ctx ))
186
186
r .Mount ("/api/v1" , apiv1 .Routes (ctx ))
187
187
r .Mount ("/api/internal" , private .Routes ())
188
+
188
189
if setting .Packages .Enabled {
189
- r .Mount ("/api/packages" , packages_router .Routes (ctx ))
190
- r .Mount ("/v2" , packages_router .ContainerRoutes (ctx ))
190
+ // Add endpoints to match common package manager APIs
191
+
192
+ // This implements package support for most package managers
193
+ r .Mount ("/api/packages" , packages_router .CommonRoutes (ctx ))
194
+
195
+ // This implements Docker HUB API (Note this is not preceded by /api but is instead /v2)
196
+ r .Mount ("/v2" , packages_router .DockerContainerRoutes (ctx ))
191
197
}
192
198
return r
193
199
}
You can’t perform that action at this time.
0 commit comments