mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user