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
This commit is contained in:
parent
17baf1af10
commit
43c7a2e7b1
177 changed files with 837 additions and 837 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue