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/web/org/teams.go | |
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/web/org/teams.go')
-rw-r--r-- | routers/web/org/teams.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index 144d9b1b43..aaac1177ae 100644 --- a/routers/web/org/teams.go +++ b/routers/web/org/teams.go @@ -72,7 +72,7 @@ func Teams(ctx *context.Context) { func TeamsAction(ctx *context.Context) { page := ctx.FormString("page") var err error - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "join": if !ctx.Org.IsOwner { ctx.Error(http.StatusNotFound) @@ -85,7 +85,7 @@ func TeamsAction(ctx *context.Context) { if org_model.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) } else { - log.Error("Action(%s): %v", ctx.Params(":action"), err) + log.Error("Action(%s): %v", ctx.PathParam(":action"), err) ctx.JSON(http.StatusOK, map[string]any{ "ok": false, "err": err.Error(), @@ -112,7 +112,7 @@ func TeamsAction(ctx *context.Context) { if org_model.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) } else { - log.Error("Action(%s): %v", ctx.Params(":action"), err) + log.Error("Action(%s): %v", ctx.PathParam(":action"), err) ctx.JSON(http.StatusOK, map[string]any{ "ok": false, "err": err.Error(), @@ -179,7 +179,7 @@ func TeamsAction(ctx *context.Context) { } if err := org_model.RemoveInviteByID(ctx, iid, ctx.Org.Team.ID); err != nil { - log.Error("Action(%s): %v", ctx.Params(":action"), err) + log.Error("Action(%s): %v", ctx.PathParam(":action"), err) ctx.ServerError("RemoveInviteByID", err) return } @@ -193,7 +193,7 @@ func TeamsAction(ctx *context.Context) { } else if errors.Is(err, user_model.ErrBlockedUser) { ctx.Flash.Error(ctx.Tr("org.teams.members.blocked_user")) } else { - log.Error("Action(%s): %v", ctx.Params(":action"), err) + log.Error("Action(%s): %v", ctx.PathParam(":action"), err) ctx.JSON(http.StatusOK, map[string]any{ "ok": false, "err": err.Error(), @@ -234,7 +234,7 @@ func TeamsRepoAction(ctx *context.Context) { } var err error - action := ctx.Params(":action") + action := ctx.PathParam(":action") switch action { case "add": repoName := path.Base(ctx.FormString("repo_name")) @@ -259,7 +259,7 @@ func TeamsRepoAction(ctx *context.Context) { } if err != nil { - log.Error("Action(%s): '%s' %v", ctx.Params(":action"), ctx.Org.Team.Name, err) + log.Error("Action(%s): '%s' %v", ctx.PathParam(":action"), ctx.Org.Team.Name, err) ctx.ServerError("TeamsRepoAction", err) return } @@ -606,7 +606,7 @@ func TeamInvitePost(ctx *context.Context) { } func getTeamInviteFromContext(ctx *context.Context) (*org_model.TeamInvite, *org_model.Organization, *org_model.Team, *user_model.User, error) { - invite, err := org_model.GetInviteByToken(ctx, ctx.Params("token")) + invite, err := org_model.GetInviteByToken(ctx, ctx.PathParam("token")) if err != nil { return nil, nil, nil, nil, err } |