aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/packages
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-06-19 06:32:45 +0800
committerGitHub <noreply@github.com>2024-06-19 06:32:45 +0800
commit43c7a2e7b1c7fb8aa2347d82ad0a6886d6fad9c2 (patch)
treec98c2e1159ee02eb52282811f28a4c31ad222c67 /routers/api/packages
parent17baf1af10de025a47ade1f16f1e5c51646d7fcf (diff)
downloadgitea-43c7a2e7b1c7fb8aa2347d82ad0a6886d6fad9c2.tar.gz
gitea-43c7a2e7b1c7fb8aa2347d82ad0a6886d6fad9c2.zip
Refactor names (#31405)
This PR only does "renaming": * `Route` should be `Router` (and chi router is also called "router") * `Params` should be `PathParam` (to distingush it from URL query param, and to match `FormString`) * Use lower case for private functions to avoid exposing or abusing
Diffstat (limited to 'routers/api/packages')
-rw-r--r--routers/api/packages/alpine/alpine.go18
-rw-r--r--routers/api/packages/api.go80
-rw-r--r--routers/api/packages/cargo/cargo.go10
-rw-r--r--routers/api/packages/chef/chef.go14
-rw-r--r--routers/api/packages/composer/composer.go10
-rw-r--r--routers/api/packages/conan/conan.go18
-rw-r--r--routers/api/packages/conda/conda.go16
-rw-r--r--routers/api/packages/container/container.go34
-rw-r--r--routers/api/packages/cran/cran.go16
-rw-r--r--routers/api/packages/debian/debian.go34
-rw-r--r--routers/api/packages/generic/generic.go20
-rw-r--r--routers/api/packages/goproxy/goproxy.go8
-rw-r--r--routers/api/packages/helm/helm.go4
-rw-r--r--routers/api/packages/maven/maven.go2
-rw-r--r--routers/api/packages/npm/npm.go16
-rw-r--r--routers/api/packages/nuget/nuget.go28
-rw-r--r--routers/api/packages/pub/pub.go14
-rw-r--r--routers/api/packages/pypi/pypi.go8
-rw-r--r--routers/api/packages/rpm/rpm.go26
-rw-r--r--routers/api/packages/rubygems/rubygems.go6
-rw-r--r--routers/api/packages/swift/swift.go22
-rw-r--r--routers/api/packages/vagrant/vagrant.go16
22 files changed, 210 insertions, 210 deletions
diff --git a/routers/api/packages/alpine/alpine.go b/routers/api/packages/alpine/alpine.go
index 5127319807..4b652c9ecc 100644
--- a/routers/api/packages/alpine/alpine.go
+++ b/routers/api/packages/alpine/alpine.go
@@ -73,7 +73,7 @@ func GetRepositoryFile(ctx *context.Context) {
pv,
&packages_service.PackageFileInfo{
Filename: alpine_service.IndexArchiveFilename,
- CompositeKey: fmt.Sprintf("%s|%s|%s", ctx.Params("branch"), ctx.Params("repository"), ctx.Params("architecture")),
+ CompositeKey: fmt.Sprintf("%s|%s|%s", ctx.PathParam("branch"), ctx.PathParam("repository"), ctx.PathParam("architecture")),
},
)
if err != nil {
@@ -89,8 +89,8 @@ func GetRepositoryFile(ctx *context.Context) {
}
func UploadPackageFile(ctx *context.Context) {
- branch := strings.TrimSpace(ctx.Params("branch"))
- repository := strings.TrimSpace(ctx.Params("repository"))
+ branch := strings.TrimSpace(ctx.PathParam("branch"))
+ repository := strings.TrimSpace(ctx.PathParam("repository"))
if branch == "" || repository == "" {
apiError(ctx, http.StatusBadRequest, "invalid branch or repository")
return
@@ -182,14 +182,14 @@ func UploadPackageFile(ctx *context.Context) {
}
func DownloadPackageFile(ctx *context.Context) {
- branch := ctx.Params("branch")
- repository := ctx.Params("repository")
- architecture := ctx.Params("architecture")
+ branch := ctx.PathParam("branch")
+ repository := ctx.PathParam("repository")
+ architecture := ctx.PathParam("architecture")
opts := &packages_model.PackageFileSearchOptions{
OwnerID: ctx.Package.Owner.ID,
PackageType: packages_model.TypeAlpine,
- Query: ctx.Params("filename"),
+ Query: ctx.PathParam("filename"),
CompositeKey: fmt.Sprintf("%s|%s|%s", branch, repository, architecture),
}
pfs, _, err := packages_model.SearchFiles(ctx, opts)
@@ -230,12 +230,12 @@ func DownloadPackageFile(ctx *context.Context) {
}
func DeletePackageFile(ctx *context.Context) {
- branch, repository, architecture := ctx.Params("branch"), ctx.Params("repository"), ctx.Params("architecture")
+ branch, repository, architecture := ctx.PathParam("branch"), ctx.PathParam("repository"), ctx.PathParam("architecture")
pfs, _, err := packages_model.SearchFiles(ctx, &packages_model.PackageFileSearchOptions{
OwnerID: ctx.Package.Owner.ID,
PackageType: packages_model.TypeAlpine,
- Query: ctx.Params("filename"),
+ Query: ctx.PathParam("filename"),
CompositeKey: fmt.Sprintf("%s|%s|%s", branch, repository, architecture),
})
if err != nil {
diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go
index 4122f632ff..0f42e8f59e 100644
--- a/routers/api/packages/api.go
+++ b/routers/api/packages/api.go
@@ -74,7 +74,7 @@ func reqPackageAccess(accessMode perm.AccessMode) func(ctx *context.Context) {
}
}
-func verifyAuth(r *web.Route, authMethods []auth.Method) {
+func verifyAuth(r *web.Router, authMethods []auth.Method) {
if setting.Service.EnableReverseProxyAuth {
authMethods = append(authMethods, &auth.ReverseProxy{})
}
@@ -94,8 +94,8 @@ func verifyAuth(r *web.Route, authMethods []auth.Method) {
// CommonRoutes provide endpoints for most package managers (except containers - see below)
// These are mounted on `/api/packages` (not `/api/v1/packages`)
-func CommonRoutes() *web.Route {
- r := web.NewRoute()
+func CommonRoutes() *web.Router {
+ r := web.NewRouter()
r.Use(context.PackageContexter())
@@ -264,15 +264,15 @@ func CommonRoutes() *web.Route {
)
r.Get("/*", func(ctx *context.Context) {
- m := downloadPattern.FindStringSubmatch(ctx.Params("*"))
+ m := downloadPattern.FindStringSubmatch(ctx.PathParam("*"))
if len(m) == 0 {
ctx.Status(http.StatusNotFound)
return
}
- ctx.SetParams("channel", strings.TrimSuffix(m[1], "/"))
- ctx.SetParams("architecture", m[2])
- ctx.SetParams("filename", m[3])
+ ctx.SetPathParam("channel", strings.TrimSuffix(m[1], "/"))
+ ctx.SetPathParam("architecture", m[2])
+ ctx.SetPathParam("filename", m[3])
switch m[3] {
case "repodata.json", "repodata.json.bz2", "current_repodata.json", "current_repodata.json.bz2":
@@ -282,14 +282,14 @@ func CommonRoutes() *web.Route {
}
})
r.Put("/*", reqPackageAccess(perm.AccessModeWrite), func(ctx *context.Context) {
- m := uploadPattern.FindStringSubmatch(ctx.Params("*"))
+ m := uploadPattern.FindStringSubmatch(ctx.PathParam("*"))
if len(m) == 0 {
ctx.Status(http.StatusNotFound)
return
}
- ctx.SetParams("channel", strings.TrimSuffix(m[1], "/"))
- ctx.SetParams("filename", m[2])
+ ctx.SetPathParam("channel", strings.TrimSuffix(m[1], "/"))
+ ctx.SetPathParam("filename", m[2])
conda.UploadPackageFile(ctx)
})
@@ -339,11 +339,11 @@ func CommonRoutes() *web.Route {
// Manual mapping of routes because the package name contains slashes which chi does not support
// https://go.dev/ref/mod#goproxy-protocol
r.Get("/*", func(ctx *context.Context) {
- path := ctx.Params("*")
+ path := ctx.PathParam("*")
if strings.HasSuffix(path, "/@latest") {
- ctx.SetParams("name", path[:len(path)-len("/@latest")])
- ctx.SetParams("version", "latest")
+ ctx.SetPathParam("name", path[:len(path)-len("/@latest")])
+ ctx.SetPathParam("version", "latest")
goproxy.PackageVersionMetadata(ctx)
return
@@ -355,7 +355,7 @@ func CommonRoutes() *web.Route {
return
}
- ctx.SetParams("name", parts[0])
+ ctx.SetPathParam("name", parts[0])
// <package/name>/@v/list
if parts[1] == "list" {
@@ -365,21 +365,21 @@ func CommonRoutes() *web.Route {
// <package/name>/@v/<version>.zip
if strings.HasSuffix(parts[1], ".zip") {
- ctx.SetParams("version", parts[1][:len(parts[1])-len(".zip")])
+ ctx.SetPathParam("version", parts[1][:len(parts[1])-len(".zip")])
goproxy.DownloadPackageFile(ctx)
return
}
// <package/name>/@v/<version>.info
if strings.HasSuffix(parts[1], ".info") {
- ctx.SetParams("version", parts[1][:len(parts[1])-len(".info")])
+ ctx.SetPathParam("version", parts[1][:len(parts[1])-len(".info")])
goproxy.PackageVersionMetadata(ctx)
return
}
// <package/name>/@v/<version>.mod
if strings.HasSuffix(parts[1], ".mod") {
- ctx.SetParams("version", parts[1][:len(parts[1])-len(".mod")])
+ ctx.SetPathParam("version", parts[1][:len(parts[1])-len(".mod")])
goproxy.PackageVersionGoModContent(ctx)
return
@@ -525,7 +525,7 @@ func CommonRoutes() *web.Route {
)
r.Methods("HEAD,GET,PUT,DELETE", "*", func(ctx *context.Context) {
- path := ctx.Params("*")
+ path := ctx.PathParam("*")
isHead := ctx.Req.Method == "HEAD"
isGetHead := ctx.Req.Method == "HEAD" || ctx.Req.Method == "GET"
isPut := ctx.Req.Method == "PUT"
@@ -533,15 +533,15 @@ func CommonRoutes() *web.Route {
m := repoPattern.FindStringSubmatch(path)
if len(m) == 2 && isGetHead {
- ctx.SetParams("group", strings.Trim(m[1], "/"))
+ ctx.SetPathParam("group", strings.Trim(m[1], "/"))
rpm.GetRepositoryConfig(ctx)
return
}
m = repoFilePattern.FindStringSubmatch(path)
if len(m) == 3 && isGetHead {
- ctx.SetParams("group", strings.Trim(m[1], "/"))
- ctx.SetParams("filename", m[2])
+ ctx.SetPathParam("group", strings.Trim(m[1], "/"))
+ ctx.SetPathParam("filename", m[2])
if isHead {
rpm.CheckRepositoryFileExistence(ctx)
} else {
@@ -556,17 +556,17 @@ func CommonRoutes() *web.Route {
if ctx.Written() {
return
}
- ctx.SetParams("group", strings.Trim(m[1], "/"))
+ ctx.SetPathParam("group", strings.Trim(m[1], "/"))
rpm.UploadPackageFile(ctx)
return
}
m = filePattern.FindStringSubmatch(path)
if len(m) == 6 && (isGetHead || isDelete) {
- ctx.SetParams("group", strings.Trim(m[1], "/"))
- ctx.SetParams("name", m[2])
- ctx.SetParams("version", m[3])
- ctx.SetParams("architecture", m[4])
+ ctx.SetPathParam("group", strings.Trim(m[1], "/"))
+ ctx.SetPathParam("name", m[2])
+ ctx.SetPathParam("version", m[3])
+ ctx.SetPathParam("architecture", m[4])
if isGetHead {
rpm.DownloadPackageFile(ctx)
} else {
@@ -607,13 +607,13 @@ func CommonRoutes() *web.Route {
r.Get("", func(ctx *context.Context) {
// Can't use normal routes here: https://github.com/go-chi/chi/issues/781
- version := ctx.Params("version")
+ version := ctx.PathParam("version")
if strings.HasSuffix(version, ".zip") {
swift.CheckAcceptMediaType(swift.AcceptZip)(ctx)
if ctx.Written() {
return
}
- ctx.SetParams("version", version[:len(version)-4])
+ ctx.SetPathParam("version", version[:len(version)-4])
swift.DownloadPackageFile(ctx)
} else {
swift.CheckAcceptMediaType(swift.AcceptJSON)(ctx)
@@ -621,7 +621,7 @@ func CommonRoutes() *web.Route {
return
}
if strings.HasSuffix(version, ".json") {
- ctx.SetParams("version", version[:len(version)-5])
+ ctx.SetPathParam("version", version[:len(version)-5])
}
swift.PackageVersionMetadata(ctx)
}
@@ -651,8 +651,8 @@ func CommonRoutes() *web.Route {
// ContainerRoutes provides endpoints that implement the OCI API to serve containers
// These have to be mounted on `/v2/...` to comply with the OCI spec:
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md
-func ContainerRoutes() *web.Route {
- r := web.NewRoute()
+func ContainerRoutes() *web.Router {
+ r := web.NewRouter()
r.Use(context.PackageContexter())
@@ -700,7 +700,7 @@ func ContainerRoutes() *web.Route {
// Manual mapping of routes because {image} can contain slashes which chi does not support
r.Methods("HEAD,GET,POST,PUT,PATCH,DELETE", "/*", func(ctx *context.Context) {
- path := ctx.Params("*")
+ path := ctx.PathParam("*")
isHead := ctx.Req.Method == "HEAD"
isGet := ctx.Req.Method == "GET"
isPost := ctx.Req.Method == "POST"
@@ -714,7 +714,7 @@ func ContainerRoutes() *web.Route {
return
}
- ctx.SetParams("image", path[:len(path)-14])
+ ctx.SetPathParam("image", path[:len(path)-14])
container.VerifyImageName(ctx)
if ctx.Written() {
return
@@ -724,7 +724,7 @@ func ContainerRoutes() *web.Route {
return
}
if isGet && strings.HasSuffix(path, "/tags/list") {
- ctx.SetParams("image", path[:len(path)-10])
+ ctx.SetPathParam("image", path[:len(path)-10])
container.VerifyImageName(ctx)
if ctx.Written() {
return
@@ -741,13 +741,13 @@ func ContainerRoutes() *web.Route {
return
}
- ctx.SetParams("image", m[1])
+ ctx.SetPathParam("image", m[1])
container.VerifyImageName(ctx)
if ctx.Written() {
return
}
- ctx.SetParams("uuid", m[2])
+ ctx.SetPathParam("uuid", m[2])
if isGet {
container.GetUploadBlob(ctx)
@@ -762,13 +762,13 @@ func ContainerRoutes() *web.Route {
}
m = blobsPattern.FindStringSubmatch(path)
if len(m) == 3 && (isHead || isGet || isDelete) {
- ctx.SetParams("image", m[1])
+ ctx.SetPathParam("image", m[1])
container.VerifyImageName(ctx)
if ctx.Written() {
return
}
- ctx.SetParams("digest", m[2])
+ ctx.SetPathParam("digest", m[2])
if isHead {
container.HeadBlob(ctx)
@@ -785,13 +785,13 @@ func ContainerRoutes() *web.Route {
}
m = manifestsPattern.FindStringSubmatch(path)
if len(m) == 3 && (isHead || isGet || isPut || isDelete) {
- ctx.SetParams("image", m[1])
+ ctx.SetPathParam("image", m[1])
container.VerifyImageName(ctx)
if ctx.Written() {
return
}
- ctx.SetParams("reference", m[2])
+ ctx.SetPathParam("reference", m[2])
if isHead {
container.HeadManifest(ctx)
diff --git a/routers/api/packages/cargo/cargo.go b/routers/api/packages/cargo/cargo.go
index 140e532efd..3d8407e6b6 100644
--- a/routers/api/packages/cargo/cargo.go
+++ b/routers/api/packages/cargo/cargo.go
@@ -55,7 +55,7 @@ func RepositoryConfig(ctx *context.Context) {
}
func EnumeratePackageVersions(ctx *context.Context) {
- p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.Params("package"))
+ p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.PathParam("package"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
@@ -173,11 +173,11 @@ func DownloadPackageFile(ctx *context.Context) {
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
PackageType: packages_model.TypeCargo,
- Name: ctx.Params("package"),
- Version: ctx.Params("version"),
+ Name: ctx.PathParam("package"),
+ Version: ctx.PathParam("version"),
},
&packages_service.PackageFileInfo{
- Filename: strings.ToLower(fmt.Sprintf("%s-%s.crate", ctx.Params("package"), ctx.Params("version"))),
+ Filename: strings.ToLower(fmt.Sprintf("%s-%s.crate", ctx.PathParam("package"), ctx.PathParam("version"))),
},
)
if err != nil {
@@ -274,7 +274,7 @@ func UnyankPackage(ctx *context.Context) {
}
func yankPackage(ctx *context.Context, yank bool) {
- pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.Params("package"), ctx.Params("version"))
+ pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.PathParam("package"), ctx.PathParam("version"))
if err != nil {
if err == packages_model.ErrPackageNotExist {
apiError(ctx, http.StatusNotFound, err)
diff --git a/routers/api/packages/chef/chef.go b/routers/api/packages/chef/chef.go
index b49f4e9d0a..b3cdf12697 100644
--- a/routers/api/packages/chef/chef.go
+++ b/routers/api/packages/chef/chef.go
@@ -150,7 +150,7 @@ func EnumeratePackages(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_show.rb
func PackageMetadata(ctx *context.Context) {
- packageName := ctx.Params("name")
+ packageName := ctx.PathParam("name")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, packageName)
if err != nil {
@@ -211,8 +211,8 @@ func PackageMetadata(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_show.rb
func PackageVersionMetadata(ctx *context.Context) {
- packageName := ctx.Params("name")
- packageVersion := strings.ReplaceAll(ctx.Params("version"), "_", ".") // Chef calls this endpoint with "_" instead of "."?!
+ packageName := ctx.PathParam("name")
+ packageVersion := strings.ReplaceAll(ctx.PathParam("version"), "_", ".") // Chef calls this endpoint with "_" instead of "."?!
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, packageName, packageVersion)
if err != nil {
@@ -325,7 +325,7 @@ func UploadPackage(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_download.rb
func DownloadPackage(ctx *context.Context) {
- pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.Params("name"), ctx.Params("version"))
+ pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.PathParam("name"), ctx.PathParam("version"))
if err != nil {
if err == packages_model.ErrPackageNotExist {
apiError(ctx, http.StatusNotFound, err)
@@ -354,8 +354,8 @@ func DownloadPackage(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_unshare.rb
func DeletePackageVersion(ctx *context.Context) {
- packageName := ctx.Params("name")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("name")
+ packageVersion := ctx.PathParam("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
ctx,
@@ -381,7 +381,7 @@ func DeletePackageVersion(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_unshare.rb
func DeletePackage(ctx *context.Context) {
- pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.Params("name"))
+ pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.PathParam("name"))
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
diff --git a/routers/api/packages/composer/composer.go b/routers/api/packages/composer/composer.go
index a045da40de..40f72f6484 100644
--- a/routers/api/packages/composer/composer.go
+++ b/routers/api/packages/composer/composer.go
@@ -134,8 +134,8 @@ func EnumeratePackages(ctx *context.Context) {
// PackageMetadata returns the metadata for a single package
// https://packagist.org/apidoc#get-package-data
func PackageMetadata(ctx *context.Context) {
- vendorName := ctx.Params("vendorname")
- projectName := ctx.Params("projectname")
+ vendorName := ctx.PathParam("vendorname")
+ projectName := ctx.PathParam("projectname")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeComposer, vendorName+"/"+projectName)
if err != nil {
@@ -168,11 +168,11 @@ func DownloadPackageFile(ctx *context.Context) {
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
PackageType: packages_model.TypeComposer,
- Name: ctx.Params("package"),
- Version: ctx.Params("version"),
+ Name: ctx.PathParam("package"),
+ Version: ctx.PathParam("version"),
},
&packages_service.PackageFileInfo{
- Filename: ctx.Params("filename"),
+ Filename: ctx.PathParam("filename"),
},
)
if err != nil {
diff --git a/routers/api/packages/conan/conan.go b/routers/api/packages/conan/conan.go
index 07ea3eda34..7afca2fab1 100644
--- a/routers/api/packages/conan/conan.go
+++ b/routers/api/packages/conan/conan.go
@@ -72,11 +72,11 @@ func baseURL(ctx *context.Context) string {
// ExtractPathParameters is a middleware to extract common parameters from path
func ExtractPathParameters(ctx *context.Context) {
rref, err := conan_module.NewRecipeReference(
- ctx.Params("name"),
- ctx.Params("version"),
- ctx.Params("user"),
- ctx.Params("channel"),
- ctx.Params("recipe_revision"),
+ ctx.PathParam("name"),
+ ctx.PathParam("version"),
+ ctx.PathParam("user"),
+ ctx.PathParam("channel"),
+ ctx.PathParam("recipe_revision"),
)
if err != nil {
apiError(ctx, http.StatusBadRequest, err)
@@ -85,14 +85,14 @@ func ExtractPathParameters(ctx *context.Context) {
ctx.Data[recipeReferenceKey] = rref
- reference := ctx.Params("package_reference")
+ reference := ctx.PathParam("package_reference")
var pref *conan_module.PackageReference
if reference != "" {
pref, err = conan_module.NewPackageReference(
rref,
reference,
- ctx.Params("package_revision"),
+ ctx.PathParam("package_revision"),
)
if err != nil {
apiError(ctx, http.StatusBadRequest, err)
@@ -304,7 +304,7 @@ func uploadFile(ctx *context.Context, fileFilter container.Set[string], fileKey
rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference)
pref := ctx.Data[packageReferenceKey].(*conan_module.PackageReference)
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
if !fileFilter.Contains(filename) {
apiError(ctx, http.StatusBadRequest, nil)
return
@@ -444,7 +444,7 @@ func DownloadPackageFile(ctx *context.Context) {
func downloadFile(ctx *context.Context, fileFilter container.Set[string], fileKey string) {
rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference)
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
if !fileFilter.Contains(filename) {
apiError(ctx, http.StatusBadRequest, nil)
return
diff --git a/routers/api/packages/conda/conda.go b/routers/api/packages/conda/conda.go
index c7e4544d52..7a46681235 100644
--- a/routers/api/packages/conda/conda.go
+++ b/routers/api/packages/conda/conda.go
@@ -66,7 +66,7 @@ func EnumeratePackages(ctx *context.Context) {
repoData := &RepoData{
Info: Info{
- Subdir: ctx.Params("architecture"),
+ Subdir: ctx.PathParam("architecture"),
},
Packages: make(map[string]*PackageInfo),
PackagesConda: make(map[string]*PackageInfo),
@@ -75,7 +75,7 @@ func EnumeratePackages(ctx *context.Context) {
pfs, err := conda_model.SearchFiles(ctx, &conda_model.FileSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Channel: ctx.Params("channel"),
+ Channel: ctx.PathParam("channel"),
Subdir: repoData.Info.Subdir,
})
if err != nil {
@@ -151,7 +151,7 @@ func EnumeratePackages(ctx *context.Context) {
var w io.Writer = resp
- if strings.HasSuffix(ctx.Params("filename"), ".json") {
+ if strings.HasSuffix(ctx.PathParam("filename"), ".json") {
resp.Header().Set("Content-Type", "application/json")
} else {
resp.Header().Set("Content-Type", "application/x-bzip2")
@@ -191,7 +191,7 @@ func UploadPackageFile(ctx *context.Context) {
defer buf.Close()
var pck *conda_module.Package
- if strings.HasSuffix(strings.ToLower(ctx.Params("filename")), ".tar.bz2") {
+ if strings.HasSuffix(strings.ToLower(ctx.PathParam("filename")), ".tar.bz2") {
pck, err = conda_module.ParsePackageBZ2(buf)
} else {
pck, err = conda_module.ParsePackageConda(buf, buf.Size())
@@ -212,7 +212,7 @@ func UploadPackageFile(ctx *context.Context) {
fullName := pck.Name
- channel := ctx.Params("channel")
+ channel := ctx.PathParam("channel")
if channel != "" {
fullName = channel + "/" + pck.Name
}
@@ -277,9 +277,9 @@ func UploadPackageFile(ctx *context.Context) {
func DownloadPackageFile(ctx *context.Context) {
pfs, err := conda_model.SearchFiles(ctx, &conda_model.FileSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Channel: ctx.Params("channel"),
- Subdir: ctx.Params("architecture"),
- Filename: ctx.Params("filename"),
+ Channel: ctx.PathParam("channel"),
+ Subdir: ctx.PathParam("architecture"),
+ Filename: ctx.PathParam("filename"),
})
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
diff --git a/routers/api/packages/container/container.go b/routers/api/packages/container/container.go
index 5007037bee..74a3295f09 100644
--- a/routers/api/packages/container/container.go
+++ b/routers/api/packages/container/container.go
@@ -131,7 +131,7 @@ func ReqContainerAccess(ctx *context.Context) {
// VerifyImageName is a middleware which checks if the image name is allowed
func VerifyImageName(ctx *context.Context) {
- if !imageNamePattern.MatchString(ctx.Params("image")) {
+ if !imageNamePattern.MatchString(ctx.PathParam("image")) {
apiErrorDefined(ctx, errNameInvalid)
}
}
@@ -216,7 +216,7 @@ func GetRepositoryList(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#single-post
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
func InitiateUploadBlob(ctx *context.Context) {
- image := ctx.Params("image")
+ image := ctx.PathParam("image")
mount := ctx.FormTrim("mount")
from := ctx.FormTrim("from")
@@ -305,7 +305,7 @@ func InitiateUploadBlob(ctx *context.Context) {
// https://docs.docker.com/registry/spec/api/#get-blob-upload
func GetUploadBlob(ctx *context.Context) {
- uuid := ctx.Params("uuid")
+ uuid := ctx.PathParam("uuid")
upload, err := packages_model.GetBlobUploadByID(ctx, uuid)
if err != nil {
@@ -326,9 +326,9 @@ func GetUploadBlob(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
func UploadBlob(ctx *context.Context) {
- image := ctx.Params("image")
+ image := ctx.PathParam("image")
- uploader, err := container_service.NewBlobUploader(ctx, ctx.Params("uuid"))
+ uploader, err := container_service.NewBlobUploader(ctx, ctx.PathParam("uuid"))
if err != nil {
if err == packages_model.ErrPackageBlobUploadNotExist {
apiErrorDefined(ctx, errBlobUploadUnknown)
@@ -371,7 +371,7 @@ func UploadBlob(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
func EndUploadBlob(ctx *context.Context) {
- image := ctx.Params("image")
+ image := ctx.PathParam("image")
digest := ctx.FormTrim("digest")
if digest == "" {
@@ -379,7 +379,7 @@ func EndUploadBlob(ctx *context.Context) {
return
}
- uploader, err := container_service.NewBlobUploader(ctx, ctx.Params("uuid"))
+ uploader, err := container_service.NewBlobUploader(ctx, ctx.PathParam("uuid"))
if err != nil {
if err == packages_model.ErrPackageBlobUploadNotExist {
apiErrorDefined(ctx, errBlobUploadUnknown)
@@ -446,7 +446,7 @@ func EndUploadBlob(ctx *context.Context) {
// https://docs.docker.com/registry/spec/api/#delete-blob-upload
func CancelUploadBlob(ctx *context.Context) {
- uuid := ctx.Params("uuid")
+ uuid := ctx.PathParam("uuid")
_, err := packages_model.GetBlobUploadByID(ctx, uuid)
if err != nil {
@@ -469,7 +469,7 @@ func CancelUploadBlob(ctx *context.Context) {
}
func getBlobFromContext(ctx *context.Context) (*packages_model.PackageFileDescriptor, error) {
- d := ctx.Params("digest")
+ d := ctx.PathParam("digest")
if digest.Digest(d).Validate() != nil {
return nil, container_model.ErrContainerBlobNotExist
@@ -477,7 +477,7 @@ func getBlobFromContext(ctx *context.Context) (*packages_model.PackageFileDescri
return workaroundGetContainerBlob(ctx, &container_model.BlobSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Image: ctx.Params("image"),
+ Image: ctx.PathParam("image"),
Digest: d,
})
}
@@ -518,14 +518,14 @@ func GetBlob(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#deleting-blobs
func DeleteBlob(ctx *context.Context) {
- d := ctx.Params("digest")
+ d := ctx.PathParam("digest")
if digest.Digest(d).Validate() != nil {
apiErrorDefined(ctx, errBlobUnknown)
return
}
- if err := deleteBlob(ctx, ctx.Package.Owner.ID, ctx.Params("image"), d); err != nil {
+ if err := deleteBlob(ctx, ctx.Package.Owner.ID, ctx.PathParam("image"), d); err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
}
@@ -537,13 +537,13 @@ func DeleteBlob(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-manifests
func UploadManifest(ctx *context.Context) {
- reference := ctx.Params("reference")
+ reference := ctx.PathParam("reference")
mci := &manifestCreationInfo{
MediaType: ctx.Req.Header.Get("Content-Type"),
Owner: ctx.Package.Owner,
Creator: ctx.Doer,
- Image: ctx.Params("image"),
+ Image: ctx.PathParam("image"),
Reference: reference,
IsTagged: digest.Digest(reference).Validate() != nil,
}
@@ -592,11 +592,11 @@ func UploadManifest(ctx *context.Context) {
}
func getBlobSearchOptionsFromContext(ctx *context.Context) (*container_model.BlobSearchOptions, error) {
- reference := ctx.Params("reference")
+ reference := ctx.PathParam("reference")
opts := &container_model.BlobSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Image: ctx.Params("image"),
+ Image: ctx.PathParam("image"),
IsManifest: true,
}
@@ -719,7 +719,7 @@ func serveBlob(ctx *context.Context, pfd *packages_model.PackageFileDescriptor)
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#content-discovery
func GetTagList(ctx *context.Context) {
- image := ctx.Params("image")
+ image := ctx.PathParam("image")
if _, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.TypeContainer, image); err != nil {
if err == packages_model.ErrPackageNotExist {
diff --git a/routers/api/packages/cran/cran.go b/routers/api/packages/cran/cran.go
index f1d616724a..8a20072cb6 100644
--- a/routers/api/packages/cran/cran.go
+++ b/routers/api/packages/cran/cran.go
@@ -28,18 +28,18 @@ func apiError(ctx *context.Context, status int, obj any) {
}
func EnumerateSourcePackages(ctx *context.Context) {
- enumeratePackages(ctx, ctx.Params("format"), &cran_model.SearchOptions{
+ enumeratePackages(ctx, ctx.PathParam("format"), &cran_model.SearchOptions{
OwnerID: ctx.Package.Owner.ID,
FileType: cran_module.TypeSource,
})
}
func EnumerateBinaryPackages(ctx *context.Context) {
- enumeratePackages(ctx, ctx.Params("format"), &cran_model.SearchOptions{
+ enumeratePackages(ctx, ctx.PathParam("format"), &cran_model.SearchOptions{
OwnerID: ctx.Package.Owner.ID,
FileType: cran_module.TypeBinary,
- Platform: ctx.Params("platform"),
- RVersion: ctx.Params("rversion"),
+ Platform: ctx.PathParam("platform"),
+ RVersion: ctx.PathParam("rversion"),
})
}
@@ -225,7 +225,7 @@ func DownloadSourcePackageFile(ctx *context.Context) {
downloadPackageFile(ctx, &cran_model.SearchOptions{
OwnerID: ctx.Package.Owner.ID,
FileType: cran_module.TypeSource,
- Filename: ctx.Params("filename"),
+ Filename: ctx.PathParam("filename"),
})
}
@@ -233,9 +233,9 @@ func DownloadBinaryPackageFile(ctx *context.Context) {
downloadPackageFile(ctx, &cran_model.SearchOptions{
OwnerID: ctx.Package.Owner.ID,
FileType: cran_module.TypeBinary,
- Platform: ctx.Params("platform"),
- RVersion: ctx.Params("rversion"),
- Filename: ctx.Params("filename"),
+ Platform: ctx.PathParam("platform"),
+ RVersion: ctx.PathParam("rversion"),
+ Filename: ctx.PathParam("filename"),
})
}
diff --git a/routers/api/packages/debian/debian.go b/routers/api/packages/debian/debian.go
index 8c05476cbc..162122ccbd 100644
--- a/routers/api/packages/debian/debian.go
+++ b/routers/api/packages/debian/debian.go
@@ -51,10 +51,10 @@ func GetRepositoryFile(ctx *context.Context) {
return
}
- key := ctx.Params("distribution")
+ key := ctx.PathParam("distribution")
- component := ctx.Params("component")
- architecture := strings.TrimPrefix(ctx.Params("architecture"), "binary-")
+ component := ctx.PathParam("component")
+ architecture := strings.TrimPrefix(ctx.PathParam("architecture"), "binary-")
if component != "" && architecture != "" {
key += "|" + component + "|" + architecture
}
@@ -63,7 +63,7 @@ func GetRepositoryFile(ctx *context.Context) {
ctx,
pv,
&packages_service.PackageFileInfo{
- Filename: ctx.Params("filename"),
+ Filename: ctx.PathParam("filename"),
CompositeKey: key,
},
)
@@ -87,14 +87,14 @@ func GetRepositoryFileByHash(ctx *context.Context) {
return
}
- algorithm := strings.ToLower(ctx.Params("algorithm"))
+ algorithm := strings.ToLower(ctx.PathParam("algorithm"))
if algorithm == "md5sum" {
algorithm = "md5"
}
pfs, _, err := packages_model.SearchFiles(ctx, &packages_model.PackageFileSearchOptions{
VersionID: pv.ID,
- Hash: strings.ToLower(ctx.Params("hash")),
+ Hash: strings.ToLower(ctx.PathParam("hash")),
HashAlgorithm: algorithm,
})
if err != nil {
@@ -120,8 +120,8 @@ func GetRepositoryFileByHash(ctx *context.Context) {
}
func UploadPackageFile(ctx *context.Context) {
- distribution := strings.TrimSpace(ctx.Params("distribution"))
- component := strings.TrimSpace(ctx.Params("component"))
+ distribution := strings.TrimSpace(ctx.PathParam("distribution"))
+ component := strings.TrimSpace(ctx.PathParam("component"))
if distribution == "" || component == "" {
apiError(ctx, http.StatusBadRequest, "invalid distribution or component")
return
@@ -207,8 +207,8 @@ func UploadPackageFile(ctx *context.Context) {
}
func DownloadPackageFile(ctx *context.Context) {
- name := ctx.Params("name")
- version := ctx.Params("version")
+ name := ctx.PathParam("name")
+ version := ctx.PathParam("version")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
@@ -219,8 +219,8 @@ func DownloadPackageFile(ctx *context.Context) {
Version: version,
},
&packages_service.PackageFileInfo{
- Filename: fmt.Sprintf("%s_%s_%s.deb", name, version, ctx.Params("architecture")),
- CompositeKey: fmt.Sprintf("%s|%s", ctx.Params("distribution"), ctx.Params("component")),
+ Filename: fmt.Sprintf("%s_%s_%s.deb", name, version, ctx.PathParam("architecture")),
+ CompositeKey: fmt.Sprintf("%s|%s", ctx.PathParam("distribution"), ctx.PathParam("component")),
},
)
if err != nil {
@@ -240,11 +240,11 @@ func DownloadPackageFile(ctx *context.Context) {
}
func DeletePackageFile(ctx *context.Context) {
- distribution := ctx.Params("distribution")
- component := ctx.Params("component")
- name := ctx.Params("name")
- version := ctx.Params("version")
- architecture := ctx.Params("architecture")
+ distribution := ctx.PathParam("distribution")
+ component := ctx.PathParam("component")
+ name := ctx.PathParam("name")
+ version := ctx.PathParam("version")
+ architecture := ctx.PathParam("architecture")
owner := ctx.Package.Owner
diff --git a/routers/api/packages/generic/generic.go b/routers/api/packages/generic/generic.go
index e66f3ee676..868caf9cf0 100644
--- a/routers/api/packages/generic/generic.go
+++ b/routers/api/packages/generic/generic.go
@@ -36,11 +36,11 @@ func DownloadPackageFile(ctx *context.Context) {
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
PackageType: packages_model.TypeGeneric,
- Name: ctx.Params("packagename"),
- Version: ctx.Params("packageversion"),
+ Name: ctx.PathParam("packagename"),
+ Version: ctx.PathParam("packageversion"),
},
&packages_service.PackageFileInfo{
- Filename: ctx.Params("filename"),
+ Filename: ctx.PathParam("filename"),
},
)
if err != nil {
@@ -71,8 +71,8 @@ func isValidFileName(filename string) bool {
// UploadPackage uploads the specific generic package.
// Duplicated packages get rejected.
func UploadPackage(ctx *context.Context) {
- packageName := ctx.Params("packagename")
- filename := ctx.Params("filename")
+ packageName := ctx.PathParam("packagename")
+ filename := ctx.PathParam("filename")
if !isValidPackageName(packageName) {
apiError(ctx, http.StatusBadRequest, errors.New("invalid package name"))
@@ -84,7 +84,7 @@ func UploadPackage(ctx *context.Context) {
return
}
- packageVersion := ctx.Params("packageversion")
+ packageVersion := ctx.PathParam("packageversion")
if packageVersion != strings.TrimSpace(packageVersion) {
apiError(ctx, http.StatusBadRequest, errors.New("invalid package version"))
return
@@ -150,8 +150,8 @@ func DeletePackage(ctx *context.Context) {
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
PackageType: packages_model.TypeGeneric,
- Name: ctx.Params("packagename"),
- Version: ctx.Params("packageversion"),
+ Name: ctx.PathParam("packagename"),
+ Version: ctx.PathParam("packageversion"),
},
)
if err != nil {
@@ -169,12 +169,12 @@ func DeletePackage(ctx *context.Context) {
// DeletePackageFile deletes the specific file of a generic package.
func DeletePackageFile(ctx *context.Context) {
pv, pf, err := func() (*packages_model.PackageVersion, *packages_model.PackageFile, error) {
- pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeGeneric, ctx.Params("packagename"), ctx.Params("packageversion"))
+ pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeGeneric, ctx.PathParam("packagename"), ctx.PathParam("packageversion"))
if err != nil {
return nil, nil, err
}
- pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.Params("filename"), packages_model.EmptyFileKey)
+ pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.PathParam("filename"), packages_model.EmptyFileKey)
if err != nil {
return nil, nil, err
}
diff --git a/routers/api/packages/goproxy/goproxy.go b/routers/api/packages/goproxy/goproxy.go
index 56a07dbd43..bde29df739 100644
--- a/routers/api/packages/goproxy/goproxy.go
+++ b/routers/api/packages/goproxy/goproxy.go
@@ -28,7 +28,7 @@ func apiError(ctx *context.Context, status int, obj any) {
}
func EnumeratePackageVersions(ctx *context.Context) {
- pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeGo, ctx.Params("name"))
+ pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeGo, ctx.PathParam("name"))
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -50,7 +50,7 @@ func EnumeratePackageVersions(ctx *context.Context) {
}
func PackageVersionMetadata(ctx *context.Context) {
- pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.Params("name"), ctx.Params("version"))
+ pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.PathParam("name"), ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
@@ -70,7 +70,7 @@ func PackageVersionMetadata(ctx *context.Context) {
}
func PackageVersionGoModContent(ctx *context.Context) {
- pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.Params("name"), ctx.Params("version"))
+ pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.PathParam("name"), ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
@@ -90,7 +90,7 @@ func PackageVersionGoModContent(ctx *context.Context) {
}
func DownloadPackageFile(ctx *context.Context) {
- pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.Params("name"), ctx.Params("version"))
+ pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.PathParam("name"), ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
diff --git a/routers/api/packages/helm/helm.go b/routers/api/packages/helm/helm.go
index efdb83ec0e..cb30a20074 100644
--- a/routers/api/packages/helm/helm.go
+++ b/routers/api/packages/helm/helm.go
@@ -101,14 +101,14 @@ func Index(ctx *context.Context) {
// DownloadPackageFile serves the content of a package
func DownloadPackageFile(ctx *context.Context) {
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
OwnerID: ctx.Package.Owner.ID,
Type: packages_model.TypeHelm,
Name: packages_model.SearchValue{
ExactMatch: true,
- Value: ctx.Params("package"),
+ Value: ctx.PathParam("package"),
},
HasFileWithName: filename,
IsInternal: optional.Some(false),
diff --git a/routers/api/packages/maven/maven.go b/routers/api/packages/maven/maven.go
index cb15eae682..1486e83c57 100644
--- a/routers/api/packages/maven/maven.go
+++ b/routers/api/packages/maven/maven.go
@@ -385,7 +385,7 @@ type parameters struct {
}
func extractPathParameters(ctx *context.Context) (parameters, error) {
- parts := strings.Split(ctx.Params("*"), "/")
+ parts := strings.Split(ctx.PathParam("*"), "/")
p := parameters{
Filename: parts[len(parts)-1],
diff --git a/routers/api/packages/npm/npm.go b/routers/api/packages/npm/npm.go
index 84acfffae2..284723e0d7 100644
--- a/routers/api/packages/npm/npm.go
+++ b/routers/api/packages/npm/npm.go
@@ -43,8 +43,8 @@ func apiError(ctx *context.Context, status int, obj any) {
// packageNameFromParams gets the package name from the url parameters
// Variations: /name/, /@scope/name/, /@scope%2Fname/
func packageNameFromParams(ctx *context.Context) string {
- scope := ctx.Params("scope")
- id := ctx.Params("id")
+ scope := ctx.PathParam("scope")
+ id := ctx.PathParam("id")
if scope != "" {
return fmt.Sprintf("@%s/%s", scope, id)
}
@@ -82,8 +82,8 @@ func PackageMetadata(ctx *context.Context) {
// DownloadPackageFile serves the content of a package
func DownloadPackageFile(ctx *context.Context) {
packageName := packageNameFromParams(ctx)
- packageVersion := ctx.Params("version")
- filename := ctx.Params("filename")
+ packageVersion := ctx.PathParam("version")
+ filename := ctx.PathParam("filename")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
@@ -111,7 +111,7 @@ func DownloadPackageFile(ctx *context.Context) {
// DownloadPackageFileByName finds the version and serves the contents of a package
func DownloadPackageFileByName(ctx *context.Context) {
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
OwnerID: ctx.Package.Owner.ID,
@@ -254,7 +254,7 @@ func DeletePreview(ctx *context.Context) {
// DeletePackageVersion deletes the package version
func DeletePackageVersion(ctx *context.Context) {
packageName := packageNameFromParams(ctx)
- packageVersion := ctx.Params("version")
+ packageVersion := ctx.PathParam("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
ctx,
@@ -349,7 +349,7 @@ func AddPackageTag(ctx *context.Context) {
return
}
- if err := setPackageTag(ctx, ctx.Params("tag"), pv, false); err != nil {
+ if err := setPackageTag(ctx, ctx.PathParam("tag"), pv, false); err != nil {
if err == errInvalidTagName {
apiError(ctx, http.StatusBadRequest, err)
return
@@ -370,7 +370,7 @@ func DeletePackageTag(ctx *context.Context) {
}
if len(pvs) != 0 {
- if err := setPackageTag(ctx, ctx.Params("tag"), pvs[0], true); err != nil {
+ if err := setPackageTag(ctx, ctx.PathParam("tag"), pvs[0], true); err != nil {
if err == errInvalidTagName {
apiError(ctx, http.StatusBadRequest, err)
return
diff --git a/routers/api/packages/nuget/nuget.go b/routers/api/packages/nuget/nuget.go
index 0d7212d7f7..70b95e6a77 100644
--- a/routers/api/packages/nuget/nuget.go
+++ b/routers/api/packages/nuget/nuget.go
@@ -226,7 +226,7 @@ func SearchServiceV3(ctx *context.Context) {
// https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-index
func RegistrationIndex(ctx *context.Context) {
- packageName := ctx.Params("id")
+ packageName := ctx.PathParam("id")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName)
if err != nil {
@@ -254,8 +254,8 @@ func RegistrationIndex(ctx *context.Context) {
// https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedQueryBuilder.cs
func RegistrationLeafV2(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName, packageVersion)
if err != nil {
@@ -283,8 +283,8 @@ func RegistrationLeafV2(ctx *context.Context) {
// https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-leaf
func RegistrationLeafV3(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := strings.TrimSuffix(ctx.Params("version"), ".json")
+ packageName := ctx.PathParam("id")
+ packageVersion := strings.TrimSuffix(ctx.PathParam("version"), ".json")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName, packageVersion)
if err != nil {
@@ -381,7 +381,7 @@ func EnumeratePackageVersionsV2Count(ctx *context.Context) {
// https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#enumerate-package-versions
func EnumeratePackageVersionsV3(ctx *context.Context) {
- packageName := ctx.Params("id")
+ packageName := ctx.PathParam("id")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName)
if err != nil {
@@ -401,9 +401,9 @@ func EnumeratePackageVersionsV3(ctx *context.Context) {
// https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-manifest-nuspec
// https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-content-nupkg
func DownloadPackageFile(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
- filename := ctx.Params("filename")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
+ filename := ctx.PathParam("filename")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
@@ -643,9 +643,9 @@ func processUploadedFile(ctx *context.Context, expectedType nuget_module.Package
// https://github.com/dotnet/symstore/blob/main/docs/specs/Simple_Symbol_Query_Protocol.md#request
func DownloadSymbolFile(ctx *context.Context) {
- filename := ctx.Params("filename")
- guid := ctx.Params("guid")[:32]
- filename2 := ctx.Params("filename2")
+ filename := ctx.PathParam("filename")
+ guid := ctx.PathParam("guid")[:32]
+ filename2 := ctx.PathParam("filename2")
if filename != filename2 {
apiError(ctx, http.StatusBadRequest, nil)
@@ -685,8 +685,8 @@ func DownloadSymbolFile(ctx *context.Context) {
// DeletePackage hard deletes the package
// https://docs.microsoft.com/en-us/nuget/api/package-publish-resource#delete-a-package
func DeletePackage(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
ctx,
diff --git a/routers/api/packages/pub/pub.go b/routers/api/packages/pub/pub.go
index f87df52a29..2be27323fd 100644
--- a/routers/api/packages/pub/pub.go
+++ b/routers/api/packages/pub/pub.go
@@ -81,7 +81,7 @@ func baseURL(ctx *context.Context) string {
// https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#list-all-versions-of-a-package
func EnumeratePackageVersions(ctx *context.Context) {
- packageName := ctx.Params("id")
+ packageName := ctx.PathParam("id")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName)
if err != nil {
@@ -119,8 +119,8 @@ func EnumeratePackageVersions(ctx *context.Context) {
// https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#deprecated-inspect-a-specific-version-of-a-package
func PackageVersionMetadata(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName, packageVersion)
if err != nil {
@@ -228,8 +228,8 @@ func UploadPackageFile(ctx *context.Context) {
// https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#publishing-packages
func FinalizePackage(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
_, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName, packageVersion)
if err != nil {
@@ -253,8 +253,8 @@ func FinalizePackage(ctx *context.Context) {
// https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#deprecated-download-a-specific-version-of-a-package
func DownloadPackageFile(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := strings.TrimSuffix(ctx.Params("version"), ".tar.gz")
+ packageName := ctx.PathParam("id")
+ packageVersion := strings.TrimSuffix(ctx.PathParam("version"), ".tar.gz")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName, packageVersion)
if err != nil {
diff --git a/routers/api/packages/pypi/pypi.go b/routers/api/packages/pypi/pypi.go
index 7824db1823..5ea86071a9 100644
--- a/routers/api/packages/pypi/pypi.go
+++ b/routers/api/packages/pypi/pypi.go
@@ -45,7 +45,7 @@ func apiError(ctx *context.Context, status int, obj any) {
// PackageMetadata returns the metadata for a single package
func PackageMetadata(ctx *context.Context) {
- packageName := normalizer.Replace(ctx.Params("id"))
+ packageName := normalizer.Replace(ctx.PathParam("id"))
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypePyPI, packageName)
if err != nil {
@@ -76,9 +76,9 @@ func PackageMetadata(ctx *context.Context) {
// DownloadPackageFile serves the content of a package
func DownloadPackageFile(ctx *context.Context) {
- packageName := normalizer.Replace(ctx.Params("id"))
- packageVersion := ctx.Params("version")
- filename := ctx.Params("filename")
+ packageName := normalizer.Replace(ctx.PathParam("id"))
+ packageVersion := ctx.PathParam("version")
+ filename := ctx.PathParam("filename")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
diff --git a/routers/api/packages/rpm/rpm.go b/routers/api/packages/rpm/rpm.go
index c59366992c..11d7729eec 100644
--- a/routers/api/packages/rpm/rpm.go
+++ b/routers/api/packages/rpm/rpm.go
@@ -33,7 +33,7 @@ func apiError(ctx *context.Context, status int, obj any) {
// https://dnf.readthedocs.io/en/latest/conf_ref.html
func GetRepositoryConfig(ctx *context.Context) {
- group := ctx.Params("group")
+ group := ctx.PathParam("group")
var groupParts []string
if group != "" {
@@ -71,7 +71,7 @@ func CheckRepositoryFileExistence(ctx *context.Context) {
return
}
- pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.Params("filename"), ctx.Params("group"))
+ pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.PathParam("filename"), ctx.PathParam("group"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
ctx.Status(http.StatusNotFound)
@@ -100,8 +100,8 @@ func GetRepositoryFile(ctx *context.Context) {
ctx,
pv,
&packages_service.PackageFileInfo{
- Filename: ctx.Params("filename"),
- CompositeKey: ctx.Params("group"),
+ Filename: ctx.PathParam("filename"),
+ CompositeKey: ctx.PathParam("group"),
},
)
if err != nil {
@@ -153,7 +153,7 @@ func UploadPackageFile(ctx *context.Context) {
apiError(ctx, http.StatusInternalServerError, err)
return
}
- group := ctx.Params("group")
+ group := ctx.PathParam("group")
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
ctx,
&packages_service.PackageCreationInfo{
@@ -202,8 +202,8 @@ func UploadPackageFile(ctx *context.Context) {
}
func DownloadPackageFile(ctx *context.Context) {
- name := ctx.Params("name")
- version := ctx.Params("version")
+ name := ctx.PathParam("name")
+ version := ctx.PathParam("version")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
@@ -214,8 +214,8 @@ func DownloadPackageFile(ctx *context.Context) {
Version: version,
},
&packages_service.PackageFileInfo{
- Filename: fmt.Sprintf("%s-%s.%s.rpm", name, version, ctx.Params("architecture")),
- CompositeKey: ctx.Params("group"),
+ Filename: fmt.Sprintf("%s-%s.%s.rpm", name, version, ctx.PathParam("architecture")),
+ CompositeKey: ctx.PathParam("group"),
},
)
if err != nil {
@@ -231,10 +231,10 @@ func DownloadPackageFile(ctx *context.Context) {
}
func DeletePackageFile(webctx *context.Context) {
- group := webctx.Params("group")
- name := webctx.Params("name")
- version := webctx.Params("version")
- architecture := webctx.Params("architecture")
+ group := webctx.PathParam("group")
+ name := webctx.PathParam("name")
+ version := webctx.PathParam("version")
+ architecture := webctx.PathParam("architecture")
var pd *packages_model.PackageDescriptor
diff --git a/routers/api/packages/rubygems/rubygems.go b/routers/api/packages/rubygems/rubygems.go
index 0a08378b47..958063e70a 100644
--- a/routers/api/packages/rubygems/rubygems.go
+++ b/routers/api/packages/rubygems/rubygems.go
@@ -95,7 +95,7 @@ func enumeratePackages(ctx *context.Context, filename string, pvs []*packages_mo
// ServePackageSpecification serves the compressed Gemspec file of a package
func ServePackageSpecification(ctx *context.Context) {
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
if !strings.HasSuffix(filename, ".gemspec.rz") {
apiError(ctx, http.StatusNotImplemented, nil)
@@ -164,7 +164,7 @@ func ServePackageSpecification(ctx *context.Context) {
// DownloadPackageFile serves the content of a package
func DownloadPackageFile(ctx *context.Context) {
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
pvs, err := getVersionsByFilename(ctx, filename)
if err != nil {
@@ -299,7 +299,7 @@ func DeletePackage(ctx *context.Context) {
// GetPackageInfo returns a custom text based format for the single rubygem with a line for each version of the rubygem
// ref: https://guides.rubygems.org/rubygems-org-compact-index-api/
func GetPackageInfo(ctx *context.Context) {
- packageName := ctx.Params("packagename")
+ packageName := ctx.PathParam("packagename")
versions, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems, packageName)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
diff --git a/routers/api/packages/swift/swift.go b/routers/api/packages/swift/swift.go
index a9da3ea9c2..d5d4d4e9d1 100644
--- a/routers/api/packages/swift/swift.go
+++ b/routers/api/packages/swift/swift.go
@@ -115,8 +115,8 @@ type EnumeratePackageVersionsResponse struct {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#41-list-package-releases
func EnumeratePackageVersions(ctx *context.Context) {
- packageScope := ctx.Params("scope")
- packageName := ctx.Params("name")
+ packageScope := ctx.PathParam("scope")
+ packageName := ctx.PathParam("name")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(packageScope, packageName))
if err != nil {
@@ -172,9 +172,9 @@ type PackageVersionMetadataResponse struct {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#endpoint-2
func PackageVersionMetadata(ctx *context.Context) {
- id := buildPackageID(ctx.Params("scope"), ctx.Params("name"))
+ id := buildPackageID(ctx.PathParam("scope"), ctx.PathParam("name"))
- pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, id, ctx.Params("version"))
+ pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, id, ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
@@ -230,9 +230,9 @@ func PackageVersionMetadata(ctx *context.Context) {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#43-fetch-manifest-for-a-package-release
func DownloadManifest(ctx *context.Context) {
- packageScope := ctx.Params("scope")
- packageName := ctx.Params("name")
- packageVersion := ctx.Params("version")
+ packageScope := ctx.PathParam("scope")
+ packageName := ctx.PathParam("name")
+ packageVersion := ctx.PathParam("version")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(packageScope, packageName), packageVersion)
if err != nil {
@@ -282,10 +282,10 @@ func DownloadManifest(ctx *context.Context) {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#endpoint-6
func UploadPackageFile(ctx *context.Context) {
- packageScope := ctx.Params("scope")
- packageName := ctx.Params("name")
+ packageScope := ctx.PathParam("scope")
+ packageName := ctx.PathParam("name")
- v, err := version.NewVersion(ctx.Params("version"))
+ v, err := version.NewVersion(ctx.PathParam("version"))
if !scopePattern.MatchString(packageScope) || !namePattern.MatchString(packageName) || err != nil {
apiError(ctx, http.StatusBadRequest, err)
@@ -381,7 +381,7 @@ func UploadPackageFile(ctx *context.Context) {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#endpoint-4
func DownloadPackageFile(ctx *context.Context) {
- pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(ctx.Params("scope"), ctx.Params("name")), ctx.Params("version"))
+ pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(ctx.PathParam("scope"), ctx.PathParam("name")), ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
diff --git a/routers/api/packages/vagrant/vagrant.go b/routers/api/packages/vagrant/vagrant.go
index 98a81da368..1daf2a0527 100644
--- a/routers/api/packages/vagrant/vagrant.go
+++ b/routers/api/packages/vagrant/vagrant.go
@@ -44,7 +44,7 @@ func CheckAuthenticate(ctx *context.Context) {
}
func CheckBoxAvailable(ctx *context.Context) {
- pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.Params("name"))
+ pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.PathParam("name"))
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -101,7 +101,7 @@ func packageDescriptorToMetadata(baseURL string, pd *packages_model.PackageDescr
}
func EnumeratePackageVersions(ctx *context.Context) {
- pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.Params("name"))
+ pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.PathParam("name"))
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -136,14 +136,14 @@ func EnumeratePackageVersions(ctx *context.Context) {
}
func UploadPackageFile(ctx *context.Context) {
- boxName := ctx.Params("name")
- boxVersion := ctx.Params("version")
+ boxName := ctx.PathParam("name")
+ boxVersion := ctx.PathParam("version")
_, err := version.NewSemver(boxVersion)
if err != nil {
apiError(ctx, http.StatusBadRequest, err)
return
}
- boxProvider := ctx.Params("provider")
+ boxProvider := ctx.PathParam("provider")
if !strings.HasSuffix(boxProvider, ".box") {
apiError(ctx, http.StatusBadRequest, err)
return
@@ -222,11 +222,11 @@ func DownloadPackageFile(ctx *context.Context) {
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
PackageType: packages_model.TypeVagrant,
- Name: ctx.Params("name"),
- Version: ctx.Params("version"),
+ Name: ctx.PathParam("name"),
+ Version: ctx.PathParam("version"),
},
&packages_service.PackageFileInfo{
- Filename: ctx.Params("provider"),
+ Filename: ctx.PathParam("provider"),
},
)
if err != nil {