aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/packages/debian
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/debian
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/debian')
-rw-r--r--routers/api/packages/debian/debian.go34
1 files changed, 17 insertions, 17 deletions
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