diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-06-19 06:32:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 06:32:45 +0800 |
commit | 43c7a2e7b1c7fb8aa2347d82ad0a6886d6fad9c2 (patch) | |
tree | c98c2e1159ee02eb52282811f28a4c31ad222c67 /routers/api/packages/conda | |
parent | 17baf1af10de025a47ade1f16f1e5c51646d7fcf (diff) | |
download | gitea-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/conda')
-rw-r--r-- | routers/api/packages/conda/conda.go | 16 |
1 files changed, 8 insertions, 8 deletions
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) |