Add some documentation to packages
In #21637 it was mentioned that the purpose of the API routes for the packages is unclear. This PR adds some documentation. Fix #21637 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
9a70a12a34
commit
82f6200d3c
3 changed files with 15 additions and 4 deletions
|
@ -40,7 +40,9 @@ func reqPackageAccess(accessMode perm.AccessMode) func(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Routes(ctx gocontext.Context) *web.Route {
|
// CommonRoutes provide endpoints for most package managers (excepting docker HUB - see below)
|
||||||
|
// These are mounted on `/api/packages` (not `/api/v1/packages`)
|
||||||
|
func CommonRoutes(ctx gocontext.Context) *web.Route {
|
||||||
r := web.NewRoute()
|
r := web.NewRoute()
|
||||||
|
|
||||||
r.Use(context.PackageContexter(ctx))
|
r.Use(context.PackageContexter(ctx))
|
||||||
|
@ -301,7 +303,9 @@ func Routes(ctx gocontext.Context) *web.Route {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContainerRoutes(ctx gocontext.Context) *web.Route {
|
// DockerContainerRoutes provides endpoints that match the Docker HUB API in order for facilitate downloading packages a docker packages
|
||||||
|
// These have to be mounted on `/v2/...` due to compatibility with the Docker HUB API
|
||||||
|
func DockerContainerRoutes(ctx gocontext.Context) *web.Route {
|
||||||
r := web.NewRoute()
|
r := web.NewRoute()
|
||||||
|
|
||||||
r.Use(context.PackageContexter(ctx))
|
r.Use(context.PackageContexter(ctx))
|
||||||
|
|
|
@ -1073,6 +1073,7 @@ func Routes(ctx gocontext.Context) *web.Route {
|
||||||
}, repoAssignment())
|
}, repoAssignment())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// NOTE: these are Gitea package management API - see packages.CommonRoutes and packages.DockerContainerRoutes for endpoints to see implementations of package manager APIs
|
||||||
m.Group("/packages/{username}", func() {
|
m.Group("/packages/{username}", func() {
|
||||||
m.Group("/{type}/{name}/{version}", func() {
|
m.Group("/{type}/{name}/{version}", func() {
|
||||||
m.Get("", packages.GetPackage)
|
m.Get("", packages.GetPackage)
|
||||||
|
|
|
@ -185,9 +185,15 @@ func NormalRoutes(ctx context.Context) *web.Route {
|
||||||
r.Mount("/", web_routers.Routes(ctx))
|
r.Mount("/", web_routers.Routes(ctx))
|
||||||
r.Mount("/api/v1", apiv1.Routes(ctx))
|
r.Mount("/api/v1", apiv1.Routes(ctx))
|
||||||
r.Mount("/api/internal", private.Routes())
|
r.Mount("/api/internal", private.Routes())
|
||||||
|
|
||||||
if setting.Packages.Enabled {
|
if setting.Packages.Enabled {
|
||||||
r.Mount("/api/packages", packages_router.Routes(ctx))
|
// Add endpoints to match common package manager APIs
|
||||||
r.Mount("/v2", packages_router.ContainerRoutes(ctx))
|
|
||||||
|
// This implements package support for most package managers
|
||||||
|
r.Mount("/api/packages", packages_router.CommonRoutes(ctx))
|
||||||
|
|
||||||
|
// This implements Docker HUB API (Note this is not preceded by /api but is instead /v2)
|
||||||
|
r.Mount("/v2", packages_router.DockerContainerRoutes(ctx))
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue