aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-12-24 21:47:45 +0800
committerGitHub <noreply@github.com>2024-12-24 13:47:45 +0000
commit2a828e2798d5f77e768e1199d88a00996bd3e45a (patch)
tree2073e3384d41675feae64dd38e79168ae25b8a33 /routers/web
parentb8b690feb958dffb51eb1d5fc86c16996ba830e1 (diff)
downloadgitea-2a828e2798d5f77e768e1199d88a00996bd3e45a.tar.gz
gitea-2a828e2798d5f77e768e1199d88a00996bd3e45a.zip
Clarify path param naming (#32969)
In history (from some legacy frameworks), both `:name` and `name` are supported as path path name, `:name` is an alias to `name`. To make code consistent, now we should only use `name` but not `:name`. Also added panic check in related functions to make sure the name won't be abused in case some downstreams still use them.
Diffstat (limited to 'routers/web')
-rw-r--r--routers/web/admin/auths.go8
-rw-r--r--routers/web/admin/users.go16
-rw-r--r--routers/web/auth/oauth.go4
-rw-r--r--routers/web/feed/render.go2
-rw-r--r--routers/web/org/home.go4
-rw-r--r--routers/web/org/members.go6
-rw-r--r--routers/web/org/projects.go32
-rw-r--r--routers/web/org/projects_test.go4
-rw-r--r--routers/web/org/teams.go14
-rw-r--r--routers/web/repo/attachment.go2
-rw-r--r--routers/web/repo/cherry_pick.go12
-rw-r--r--routers/web/repo/commit.go8
-rw-r--r--routers/web/repo/editor_test.go4
-rw-r--r--routers/web/repo/githttp.go4
-rw-r--r--routers/web/repo/issue.go10
-rw-r--r--routers/web/repo/issue_comment.go12
-rw-r--r--routers/web/repo/issue_list.go2
-rw-r--r--routers/web/repo/issue_pin.go2
-rw-r--r--routers/web/repo/issue_timetrack.go2
-rw-r--r--routers/web/repo/issue_view.go10
-rw-r--r--routers/web/repo/milestone.go12
-rw-r--r--routers/web/repo/projects.go32
-rw-r--r--routers/web/repo/projects_test.go4
-rw-r--r--routers/web/repo/pull.go6
-rw-r--r--routers/web/repo/repo.go12
-rw-r--r--routers/web/repo/setting/git_hooks.go4
-rw-r--r--routers/web/repo/setting/protected_tag.go2
-rw-r--r--routers/web/repo/setting/runners.go8
-rw-r--r--routers/web/repo/setting/webhook.go16
-rw-r--r--routers/web/repo/view_home.go2
-rw-r--r--routers/web/shared/actions/variables.go4
-rw-r--r--routers/web/shared/project/column.go2
-rw-r--r--routers/web/user/avatar.go6
-rw-r--r--routers/web/user/home.go2
-rw-r--r--routers/web/user/package.go2
35 files changed, 136 insertions, 136 deletions
diff --git a/routers/web/admin/auths.go b/routers/web/admin/auths.go
index 6a65cfa697..249347e835 100644
--- a/routers/web/admin/auths.go
+++ b/routers/web/admin/auths.go
@@ -337,7 +337,7 @@ func EditAuthSource(ctx *context.Context) {
oauth2providers := oauth2.GetSupportedOAuth2Providers()
ctx.Data["OAuth2Providers"] = oauth2providers
- source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64(":authid"))
+ source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64("authid"))
if err != nil {
ctx.ServerError("auth.GetSourceByID", err)
return
@@ -371,7 +371,7 @@ func EditAuthSourcePost(ctx *context.Context) {
oauth2providers := oauth2.GetSupportedOAuth2Providers()
ctx.Data["OAuth2Providers"] = oauth2providers
- source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64(":authid"))
+ source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64("authid"))
if err != nil {
ctx.ServerError("auth.GetSourceByID", err)
return
@@ -442,7 +442,7 @@ func EditAuthSourcePost(ctx *context.Context) {
// DeleteAuthSource response for deleting an auth source
func DeleteAuthSource(ctx *context.Context) {
- source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64(":authid"))
+ source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64("authid"))
if err != nil {
ctx.ServerError("auth.GetSourceByID", err)
return
@@ -454,7 +454,7 @@ func DeleteAuthSource(ctx *context.Context) {
} else {
ctx.Flash.Error(fmt.Sprintf("auth_service.DeleteSource: %v", err))
}
- ctx.JSONRedirect(setting.AppSubURL + "/-/admin/auths/" + url.PathEscape(ctx.PathParam(":authid")))
+ ctx.JSONRedirect(setting.AppSubURL + "/-/admin/auths/" + url.PathEscape(ctx.PathParam("authid")))
return
}
log.Trace("Authentication deleted by admin(%s): %d", ctx.Doer.Name, source.ID)
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index cf158f7aa9..fdd18b2f9d 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -219,7 +219,7 @@ func NewUserPost(ctx *context.Context) {
}
func prepareUserInfo(ctx *context.Context) *user_model.User {
- u, err := user_model.GetUserByID(ctx, ctx.PathParamInt64(":userid"))
+ u, err := user_model.GetUserByID(ctx, ctx.PathParamInt64("userid"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Redirect(setting.AppSubURL + "/-/admin/users")
@@ -481,12 +481,12 @@ func EditUserPost(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("admin.users.update_profile_success"))
- ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam("userid")))
}
// DeleteUser response for deleting a user
func DeleteUser(ctx *context.Context) {
- u, err := user_model.GetUserByID(ctx, ctx.PathParamInt64(":userid"))
+ u, err := user_model.GetUserByID(ctx, ctx.PathParamInt64("userid"))
if err != nil {
ctx.ServerError("GetUserByID", err)
return
@@ -495,7 +495,7 @@ func DeleteUser(ctx *context.Context) {
// admin should not delete themself
if u.ID == ctx.Doer.ID {
ctx.Flash.Error(ctx.Tr("admin.users.cannot_delete_self"))
- ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam("userid")))
return
}
@@ -503,16 +503,16 @@ func DeleteUser(ctx *context.Context) {
switch {
case repo_model.IsErrUserOwnRepos(err):
ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo"))
- ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam("userid")))
case org_model.IsErrUserHasOrgs(err):
ctx.Flash.Error(ctx.Tr("admin.users.still_has_org"))
- ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam("userid")))
case packages_model.IsErrUserOwnPackages(err):
ctx.Flash.Error(ctx.Tr("admin.users.still_own_packages"))
- ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam("userid")))
case user_model.IsErrDeleteLastAdminUser(err):
ctx.Flash.Error(ctx.Tr("auth.last_admin"))
- ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam("userid")))
default:
ctx.ServerError("DeleteUser", err)
}
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index 32c30c71e8..7a9721cf56 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -34,7 +34,7 @@ import (
// SignInOAuth handles the OAuth2 login buttons
func SignInOAuth(ctx *context.Context) {
- provider := ctx.PathParam(":provider")
+ provider := ctx.PathParam("provider")
authSource, err := auth.GetActiveOAuth2SourceByName(ctx, provider)
if err != nil {
@@ -73,7 +73,7 @@ func SignInOAuth(ctx *context.Context) {
// SignInOAuthCallback handles the callback from the given provider
func SignInOAuthCallback(ctx *context.Context) {
- provider := ctx.PathParam(":provider")
+ provider := ctx.PathParam("provider")
if ctx.Req.FormValue("error") != "" {
var errorKeyValues []string
diff --git a/routers/web/feed/render.go b/routers/web/feed/render.go
index f975fc7cb2..462ebb97b5 100644
--- a/routers/web/feed/render.go
+++ b/routers/web/feed/render.go
@@ -9,7 +9,7 @@ import (
// RenderBranchFeed render format for branch or file
func RenderBranchFeed(ctx *context.Context) {
- _, _, showFeedType := GetFeedType(ctx.PathParam(":reponame"), ctx.Req)
+ _, _, showFeedType := GetFeedType(ctx.PathParam("reponame"), ctx.Req)
if ctx.Repo.TreePath == "" {
ShowBranchFeed(ctx, ctx.Repo.Repository, showFeedType)
} else {
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index 7122aff6bd..bdc43acc30 100644
--- a/routers/web/org/home.go
+++ b/routers/web/org/home.go
@@ -28,14 +28,14 @@ const (
// Home show organization home page
func Home(ctx *context.Context) {
- uname := ctx.PathParam(":username")
+ uname := ctx.PathParam("username")
if strings.HasSuffix(uname, ".keys") || strings.HasSuffix(uname, ".gpg") {
ctx.NotFound("", nil)
return
}
- ctx.SetPathParam(":org", uname)
+ ctx.SetPathParam("org", uname)
context.HandleOrgAssignment(ctx)
if ctx.Written() {
return
diff --git a/routers/web/org/members.go b/routers/web/org/members.go
index f91062957e..5a134caecb 100644
--- a/routers/web/org/members.go
+++ b/routers/web/org/members.go
@@ -90,7 +90,7 @@ func MembersAction(ctx *context.Context) {
org := ctx.Org.Organization
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "private":
if ctx.Doer.ID != member.ID && !ctx.Org.IsOwner {
ctx.Error(http.StatusNotFound)
@@ -131,7 +131,7 @@ func MembersAction(ctx *context.Context) {
}
if err != nil {
- log.Error("Action(%s): %v", ctx.PathParam(":action"), err)
+ log.Error("Action(%s): %v", ctx.PathParam("action"), err)
ctx.JSON(http.StatusOK, map[string]any{
"ok": false,
"err": err.Error(),
@@ -140,7 +140,7 @@ func MembersAction(ctx *context.Context) {
}
redirect := ctx.Org.OrgLink + "/members"
- if ctx.PathParam(":action") == "leave" {
+ if ctx.PathParam("action") == "leave" {
redirect = setting.AppSubURL + "/"
}
diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go
index 08201e5eaa..efcc8fadc8 100644
--- a/routers/web/org/projects.go
+++ b/routers/web/org/projects.go
@@ -196,7 +196,7 @@ func NewProjectPost(ctx *context.Context) {
// ChangeProjectStatus updates the status of a project between "open" and "close"
func ChangeProjectStatus(ctx *context.Context) {
var toClose bool
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "open":
toClose = false
case "close":
@@ -205,7 +205,7 @@ func ChangeProjectStatus(ctx *context.Context) {
ctx.JSONRedirect(ctx.ContextUser.HomeLink() + "/-/projects")
return
}
- id := ctx.PathParamInt64(":id")
+ id := ctx.PathParamInt64("id")
if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, 0, id, toClose); err != nil {
ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err)
@@ -216,7 +216,7 @@ func ChangeProjectStatus(ctx *context.Context) {
// DeleteProject delete a project
func DeleteProject(ctx *context.Context) {
- p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -245,7 +245,7 @@ func RenderEditProject(ctx *context.Context) {
shared_user.RenderUserHeader(ctx)
- p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -269,7 +269,7 @@ func RenderEditProject(ctx *context.Context) {
// EditProjectPost response for editing a project
func EditProjectPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.CreateProjectForm)
- projectID := ctx.PathParamInt64(":id")
+ projectID := ctx.PathParamInt64("id")
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
ctx.Data["PageIsEditProjects"] = true
ctx.Data["PageIsViewProjects"] = true
@@ -318,7 +318,7 @@ func EditProjectPost(ctx *context.Context) {
// ViewProject renders the project with board view for a project
func ViewProject(ctx *context.Context) {
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -447,18 +447,18 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
}
- pb, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
+ pb, err := project_model.GetColumn(ctx, ctx.PathParamInt64("columnID"))
if err != nil {
ctx.ServerError("GetProjectColumn", err)
return
}
- if pb.ProjectID != ctx.PathParamInt64(":id") {
+ if pb.ProjectID != ctx.PathParamInt64("id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", pb.ID, project.ID),
})
@@ -472,7 +472,7 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- if err := project_model.DeleteColumnByID(ctx, ctx.PathParamInt64(":columnID")); err != nil {
+ if err := project_model.DeleteColumnByID(ctx, ctx.PathParamInt64("columnID")); err != nil {
ctx.ServerError("DeleteProjectColumnByID", err)
return
}
@@ -484,7 +484,7 @@ func DeleteProjectColumn(ctx *context.Context) {
func AddColumnToProjectPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditProjectColumnForm)
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -512,18 +512,18 @@ func CheckProjectColumnChangePermissions(ctx *context.Context) (*project_model.P
return nil, nil
}
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return nil, nil
}
- column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
+ column, err := project_model.GetColumn(ctx, ctx.PathParamInt64("columnID"))
if err != nil {
ctx.ServerError("GetProjectColumn", err)
return nil, nil
}
- if column.ProjectID != ctx.PathParamInt64(":id") {
+ if column.ProjectID != ctx.PathParamInt64("id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", column.ID, project.ID),
})
@@ -587,7 +587,7 @@ func MoveIssues(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -597,7 +597,7 @@ func MoveIssues(ctx *context.Context) {
return
}
- column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
+ column, err := project_model.GetColumn(ctx, ctx.PathParamInt64("columnID"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectColumn", project_model.IsErrProjectColumnNotExist, err)
return
diff --git a/routers/web/org/projects_test.go b/routers/web/org/projects_test.go
index c52cb7ed4c..c3a769e621 100644
--- a/routers/web/org/projects_test.go
+++ b/routers/web/org/projects_test.go
@@ -18,8 +18,8 @@ func TestCheckProjectColumnChangePermissions(t *testing.T) {
ctx, _ := contexttest.MockContext(t, "user2/-/projects/4/4")
contexttest.LoadUser(t, ctx, 2)
ctx.ContextUser = ctx.Doer // user2
- ctx.SetPathParam(":id", "4")
- ctx.SetPathParam(":columnID", "4")
+ ctx.SetPathParam("id", "4")
+ ctx.SetPathParam("columnID", "4")
project, column := org.CheckProjectColumnChangePermissions(ctx)
assert.NotNil(t, project)
diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go
index 7414a11308..0137f2cc96 100644
--- a/routers/web/org/teams.go
+++ b/routers/web/org/teams.go
@@ -71,7 +71,7 @@ func Teams(ctx *context.Context) {
func TeamsAction(ctx *context.Context) {
page := ctx.FormString("page")
var err error
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "join":
if !ctx.Org.IsOwner {
ctx.Error(http.StatusNotFound)
@@ -84,7 +84,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.PathParam(":action"), err)
+ log.Error("Action(%s): %v", ctx.PathParam("action"), err)
ctx.JSON(http.StatusOK, map[string]any{
"ok": false,
"err": err.Error(),
@@ -111,7 +111,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.PathParam(":action"), err)
+ log.Error("Action(%s): %v", ctx.PathParam("action"), err)
ctx.JSON(http.StatusOK, map[string]any{
"ok": false,
"err": err.Error(),
@@ -178,7 +178,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.PathParam(":action"), err)
+ log.Error("Action(%s): %v", ctx.PathParam("action"), err)
ctx.ServerError("RemoveInviteByID", err)
return
}
@@ -192,7 +192,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.PathParam(":action"), err)
+ log.Error("Action(%s): %v", ctx.PathParam("action"), err)
ctx.JSON(http.StatusOK, map[string]any{
"ok": false,
"err": err.Error(),
@@ -233,7 +233,7 @@ func TeamsRepoAction(ctx *context.Context) {
}
var err error
- action := ctx.PathParam(":action")
+ action := ctx.PathParam("action")
switch action {
case "add":
repoName := path.Base(ctx.FormString("repo_name"))
@@ -258,7 +258,7 @@ func TeamsRepoAction(ctx *context.Context) {
}
if err != nil {
- log.Error("Action(%s): '%s' %v", ctx.PathParam(":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
}
diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go
index 04f480f611..f8e51521be 100644
--- a/routers/web/repo/attachment.go
+++ b/routers/web/repo/attachment.go
@@ -154,5 +154,5 @@ func ServeAttachment(ctx *context.Context, uuid string) {
// GetAttachment serve attachments
func GetAttachment(ctx *context.Context) {
- ServeAttachment(ctx, ctx.PathParam(":uuid"))
+ ServeAttachment(ctx, ctx.PathParam("uuid"))
}
diff --git a/routers/web/repo/cherry_pick.go b/routers/web/repo/cherry_pick.go
index 30f4c8a90e..35f158df52 100644
--- a/routers/web/repo/cherry_pick.go
+++ b/routers/web/repo/cherry_pick.go
@@ -24,8 +24,8 @@ var tplCherryPick templates.TplName = "repo/editor/cherry_pick"
// CherryPick handles cherrypick GETs
func CherryPick(ctx *context.Context) {
- ctx.Data["SHA"] = ctx.PathParam(":sha")
- cherryPickCommit, err := ctx.Repo.GitRepo.GetCommit(ctx.PathParam(":sha"))
+ ctx.Data["SHA"] = ctx.PathParam("sha")
+ cherryPickCommit, err := ctx.Repo.GitRepo.GetCommit(ctx.PathParam("sha"))
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("Missing Commit", err)
@@ -37,7 +37,7 @@ func CherryPick(ctx *context.Context) {
if ctx.FormString("cherry-pick-type") == "revert" {
ctx.Data["CherryPickType"] = "revert"
- ctx.Data["commit_summary"] = "revert " + ctx.PathParam(":sha")
+ ctx.Data["commit_summary"] = "revert " + ctx.PathParam("sha")
ctx.Data["commit_message"] = "revert " + cherryPickCommit.Message()
} else {
ctx.Data["CherryPickType"] = "cherry-pick"
@@ -66,7 +66,7 @@ func CherryPick(ctx *context.Context) {
func CherryPickPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.CherryPickForm)
- sha := ctx.PathParam(":sha")
+ sha := ctx.PathParam("sha")
ctx.Data["SHA"] = sha
if form.Revert {
ctx.Data["CherryPickType"] = "revert"
@@ -140,7 +140,7 @@ func CherryPickPost(ctx *context.Context) {
if form.Revert {
if err := git.GetReverseRawDiff(ctx, ctx.Repo.Repository.RepoPath(), sha, buf); err != nil {
if git.IsErrNotExist(err) {
- ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.PathParam(":sha")+" does not exist."))
+ ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.PathParam("sha")+" does not exist."))
return
}
ctx.ServerError("GetRawDiff", err)
@@ -149,7 +149,7 @@ func CherryPickPost(ctx *context.Context) {
} else {
if err := git.GetRawDiff(ctx.Repo.GitRepo, sha, git.RawDiffType("patch"), buf); err != nil {
if git.IsErrNotExist(err) {
- ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.PathParam(":sha")+" does not exist."))
+ ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.PathParam("sha")+" does not exist."))
return
}
ctx.ServerError("GetRawDiff", err)
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go
index 1447b17a36..6f534b9e2e 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -282,7 +282,7 @@ func Diff(ctx *context.Context) {
userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name
- commitID := ctx.PathParam(":sha")
+ commitID := ctx.PathParam("sha")
var (
gitRepo *git.Repository
err error
@@ -427,13 +427,13 @@ func RawDiff(ctx *context.Context) {
}
if err := git.GetRawDiff(
gitRepo,
- ctx.PathParam(":sha"),
- git.RawDiffType(ctx.PathParam(":ext")),
+ ctx.PathParam("sha"),
+ git.RawDiffType(ctx.PathParam("ext")),
ctx.Resp,
); err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetRawDiff",
- errors.New("commit "+ctx.PathParam(":sha")+" does not exist."))
+ errors.New("commit "+ctx.PathParam("sha")+" does not exist."))
return
}
ctx.ServerError("GetRawDiff", err)
diff --git a/routers/web/repo/editor_test.go b/routers/web/repo/editor_test.go
index 68d69408ac..566db31693 100644
--- a/routers/web/repo/editor_test.go
+++ b/routers/web/repo/editor_test.go
@@ -43,7 +43,7 @@ func TestCleanUploadName(t *testing.T) {
func TestGetUniquePatchBranchName(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetPathParam(":id", "1")
+ ctx.SetPathParam("id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -58,7 +58,7 @@ func TestGetUniquePatchBranchName(t *testing.T) {
func TestGetClosestParentWithFiles(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetPathParam(":id", "1")
+ ctx.SetPathParam("id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
diff --git a/routers/web/repo/githttp.go b/routers/web/repo/githttp.go
index a8a7a4bd79..6b2a7fd076 100644
--- a/routers/web/repo/githttp.go
+++ b/routers/web/repo/githttp.go
@@ -57,8 +57,8 @@ func CorsHandler() func(next http.Handler) http.Handler {
// httpBase implementation git smart HTTP protocol
func httpBase(ctx *context.Context) *serviceHandler {
- username := ctx.PathParam(":username")
- reponame := strings.TrimSuffix(ctx.PathParam(":reponame"), ".git")
+ username := ctx.PathParam("username")
+ reponame := strings.TrimSuffix(ctx.PathParam("reponame"), ".git")
if ctx.FormString("go-get") == "1" {
context.EarlyResponseForGoGetMeta(ctx)
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index 23012dda3d..a3a4e73d7b 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -181,7 +181,7 @@ func retrieveProjectsInternal(ctx *context.Context, repo *repo_model.Repository)
// GetActionIssue will return the issue which is used in the context.
func GetActionIssue(ctx *context.Context) *issues_model.Issue {
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
ctx.NotFoundOrServerError("GetIssueByIndex", issues_model.IsErrIssueNotExist, err)
return nil
@@ -246,7 +246,7 @@ func getActionIssues(ctx *context.Context) issues_model.IssueList {
// GetIssueInfo get an issue of a repository
func GetIssueInfo(ctx *context.Context) {
- issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
+ issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.Error(http.StatusNotFound)
@@ -379,7 +379,7 @@ func UpdateIssueContent(ctx *context.Context) {
// UpdateIssueDeadline updates an issue deadline
func UpdateIssueDeadline(ctx *context.Context) {
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound("GetIssueByIndex", err)
@@ -506,7 +506,7 @@ func ChangeIssueReaction(ctx *context.Context) {
return
}
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "react":
reaction, err := issue_service.CreateIssueReaction(ctx, ctx.Doer, issue, form.Content)
if err != nil {
@@ -540,7 +540,7 @@ func ChangeIssueReaction(ctx *context.Context) {
log.Trace("Reaction for issue removed: %d/%d", ctx.Repo.Repository.ID, issue.ID)
default:
- ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam(":action")), nil)
+ ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam("action")), nil)
return
}
diff --git a/routers/web/repo/issue_comment.go b/routers/web/repo/issue_comment.go
index 6b7b29d9d7..438822431d 100644
--- a/routers/web/repo/issue_comment.go
+++ b/routers/web/repo/issue_comment.go
@@ -209,7 +209,7 @@ func NewComment(ctx *context.Context) {
// UpdateCommentContent change comment of issue's content
func UpdateCommentContent(ctx *context.Context) {
- comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err)
return
@@ -287,7 +287,7 @@ func UpdateCommentContent(ctx *context.Context) {
// DeleteComment delete comment of issue
func DeleteComment(ctx *context.Context) {
- comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err)
return
@@ -322,7 +322,7 @@ func DeleteComment(ctx *context.Context) {
// ChangeCommentReaction create a reaction for comment
func ChangeCommentReaction(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.ReactionForm)
- comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err)
return
@@ -366,7 +366,7 @@ func ChangeCommentReaction(ctx *context.Context) {
return
}
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "react":
reaction, err := issue_service.CreateCommentReaction(ctx, ctx.Doer, comment, form.Content)
if err != nil {
@@ -400,7 +400,7 @@ func ChangeCommentReaction(ctx *context.Context) {
log.Trace("Reaction for comment removed: %d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID)
default:
- ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam(":action")), nil)
+ ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam("action")), nil)
return
}
@@ -427,7 +427,7 @@ func ChangeCommentReaction(ctx *context.Context) {
// GetCommentAttachments returns attachments for the comment
func GetCommentAttachments(ctx *context.Context) {
- comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err)
return
diff --git a/routers/web/repo/issue_list.go b/routers/web/repo/issue_list.go
index ff98bf8ec8..2c73a24632 100644
--- a/routers/web/repo/issue_list.go
+++ b/routers/web/repo/issue_list.go
@@ -748,7 +748,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
// Issues render issues page
func Issues(ctx *context.Context) {
- isPullList := ctx.PathParam(":type") == "pulls"
+ isPullList := ctx.PathParam("type") == "pulls"
if isPullList {
MustAllowPulls(ctx)
if ctx.Written() {
diff --git a/routers/web/repo/issue_pin.go b/routers/web/repo/issue_pin.go
index 0074e31f03..d7d3205c37 100644
--- a/routers/web/repo/issue_pin.go
+++ b/routers/web/repo/issue_pin.go
@@ -39,7 +39,7 @@ func IssuePinOrUnpin(ctx *context.Context) {
// IssueUnpin unpins a Issue
func IssueUnpin(ctx *context.Context) {
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
ctx.Status(http.StatusInternalServerError)
log.Error(err.Error())
diff --git a/routers/web/repo/issue_timetrack.go b/routers/web/repo/issue_timetrack.go
index 88c539488e..36e931a48f 100644
--- a/routers/web/repo/issue_timetrack.go
+++ b/routers/web/repo/issue_timetrack.go
@@ -60,7 +60,7 @@ func DeleteTime(c *context.Context) {
return
}
- t, err := issues_model.GetTrackedTimeByID(c, c.PathParamInt64(":timeid"))
+ t, err := issues_model.GetTrackedTimeByID(c, c.PathParamInt64("timeid"))
if err != nil {
if db.IsErrNotExist(err) {
c.NotFound("time not found", err)
diff --git a/routers/web/repo/issue_view.go b/routers/web/repo/issue_view.go
index 09b57f4e78..61e75e211b 100644
--- a/routers/web/repo/issue_view.go
+++ b/routers/web/repo/issue_view.go
@@ -265,13 +265,13 @@ func combineLabelComments(issue *issues_model.Issue) {
// ViewIssue render issue view page
func ViewIssue(ctx *context.Context) {
- if ctx.PathParam(":type") == "issues" {
+ if ctx.PathParam("type") == "issues" {
// If issue was requested we check if repo has external tracker and redirect
extIssueUnit, err := ctx.Repo.Repository.GetUnit(ctx, unit.TypeExternalTracker)
if err == nil && extIssueUnit != nil {
if extIssueUnit.ExternalTrackerConfig().ExternalTrackerStyle == markup.IssueNameStyleNumeric || extIssueUnit.ExternalTrackerConfig().ExternalTrackerStyle == "" {
metas := ctx.Repo.Repository.ComposeMetas(ctx)
- metas["index"] = ctx.PathParam(":index")
+ metas["index"] = ctx.PathParam("index")
res, err := vars.Expand(extIssueUnit.ExternalTrackerConfig().ExternalTrackerFormat, metas)
if err != nil {
log.Error("unable to expand template vars for issue url. issue: %s, err: %v", metas["index"], err)
@@ -287,7 +287,7 @@ func ViewIssue(ctx *context.Context) {
}
}
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound("GetIssueByIndex", err)
@@ -301,10 +301,10 @@ func ViewIssue(ctx *context.Context) {
}
// Make sure type and URL matches.
- if ctx.PathParam(":type") == "issues" && issue.IsPull {
+ if ctx.PathParam("type") == "issues" && issue.IsPull {
ctx.Redirect(issue.Link())
return
- } else if ctx.PathParam(":type") == "pulls" && !issue.IsPull {
+ } else if ctx.PathParam("type") == "pulls" && !issue.IsPull {
ctx.Redirect(issue.Link())
return
}
diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go
index d6e41a89b2..392d87167a 100644
--- a/routers/web/repo/milestone.go
+++ b/routers/web/repo/milestone.go
@@ -147,7 +147,7 @@ func EditMilestone(ctx *context.Context) {
ctx.Data["PageIsMilestones"] = true
ctx.Data["PageIsEditMilestone"] = true
- m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id"))
+ m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
if err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
ctx.NotFound("", nil)
@@ -183,7 +183,7 @@ func EditMilestonePost(ctx *context.Context) {
return
}
- m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id"))
+ m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
if err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
ctx.NotFound("", nil)
@@ -207,7 +207,7 @@ func EditMilestonePost(ctx *context.Context) {
// ChangeMilestoneStatus response for change a milestone's status
func ChangeMilestoneStatus(ctx *context.Context) {
var toClose bool
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "open":
toClose = false
case "close":
@@ -216,7 +216,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones")
return
}
- id := ctx.PathParamInt64(":id")
+ id := ctx.PathParamInt64("id")
if err := issues_model.ChangeMilestoneStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
@@ -226,7 +226,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
}
return
}
- ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.PathParam(":action")))
+ ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.PathParam("action")))
}
// DeleteMilestone delete a milestone
@@ -242,7 +242,7 @@ func DeleteMilestone(ctx *context.Context) {
// MilestoneIssuesAndPulls lists all the issues and pull requests of the milestone
func MilestoneIssuesAndPulls(ctx *context.Context) {
- milestoneID := ctx.PathParamInt64(":id")
+ milestoneID := ctx.PathParamInt64("id")
projectID := ctx.FormInt64("project")
milestone, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, milestoneID)
if err != nil {
diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go
index 92227e3f3e..4313b6c403 100644
--- a/routers/web/repo/projects.go
+++ b/routers/web/repo/projects.go
@@ -166,7 +166,7 @@ func NewProjectPost(ctx *context.Context) {
// ChangeProjectStatus updates the status of a project between "open" and "close"
func ChangeProjectStatus(ctx *context.Context) {
var toClose bool
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "open":
toClose = false
case "close":
@@ -175,7 +175,7 @@ func ChangeProjectStatus(ctx *context.Context) {
ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects")
return
}
- id := ctx.PathParamInt64(":id")
+ id := ctx.PathParamInt64("id")
if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err)
@@ -186,7 +186,7 @@ func ChangeProjectStatus(ctx *context.Context) {
// DeleteProject delete a project
func DeleteProject(ctx *context.Context) {
- p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -216,7 +216,7 @@ func RenderEditProject(ctx *context.Context) {
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
ctx.Data["CardTypes"] = project_model.GetCardConfig()
- p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -243,7 +243,7 @@ func RenderEditProject(ctx *context.Context) {
// EditProjectPost response for editing a project
func EditProjectPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.CreateProjectForm)
- projectID := ctx.PathParamInt64(":id")
+ projectID := ctx.PathParamInt64("id")
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
ctx.Data["PageIsEditProjects"] = true
@@ -288,7 +288,7 @@ func EditProjectPost(ctx *context.Context) {
// ViewProject renders the project with board view
func ViewProject(ctx *context.Context) {
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -468,7 +468,7 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -478,12 +478,12 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- pb, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
+ pb, err := project_model.GetColumn(ctx, ctx.PathParamInt64("columnID"))
if err != nil {
ctx.ServerError("GetProjectColumn", err)
return
}
- if pb.ProjectID != ctx.PathParamInt64(":id") {
+ if pb.ProjectID != ctx.PathParamInt64("id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", pb.ID, project.ID),
})
@@ -497,7 +497,7 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- if err := project_model.DeleteColumnByID(ctx, ctx.PathParamInt64(":columnID")); err != nil {
+ if err := project_model.DeleteColumnByID(ctx, ctx.PathParamInt64("columnID")); err != nil {
ctx.ServerError("DeleteProjectColumnByID", err)
return
}
@@ -515,7 +515,7 @@ func AddColumnToProjectPost(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectForRepoByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectForRepoByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -553,7 +553,7 @@ func checkProjectColumnChangePermissions(ctx *context.Context) (*project_model.P
return nil, nil
}
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -563,12 +563,12 @@ func checkProjectColumnChangePermissions(ctx *context.Context) (*project_model.P
return nil, nil
}
- column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
+ column, err := project_model.GetColumn(ctx, ctx.PathParamInt64("columnID"))
if err != nil {
ctx.ServerError("GetProjectColumn", err)
return nil, nil
}
- if column.ProjectID != ctx.PathParamInt64(":id") {
+ if column.ProjectID != ctx.PathParamInt64("id") {
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
"message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", column.ID, project.ID),
})
@@ -639,7 +639,7 @@ func MoveIssues(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("ProjectNotExist", nil)
@@ -653,7 +653,7 @@ func MoveIssues(ctx *context.Context) {
return
}
- column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
+ column, err := project_model.GetColumn(ctx, ctx.PathParamInt64("columnID"))
if err != nil {
if project_model.IsErrProjectColumnNotExist(err) {
ctx.NotFound("ProjectColumnNotExist", nil)
diff --git a/routers/web/repo/projects_test.go b/routers/web/repo/projects_test.go
index 1a42c615ab..d0690d9a4d 100644
--- a/routers/web/repo/projects_test.go
+++ b/routers/web/repo/projects_test.go
@@ -17,8 +17,8 @@ func TestCheckProjectColumnChangePermissions(t *testing.T) {
ctx, _ := contexttest.MockContext(t, "user2/repo1/projects/1/2")
contexttest.LoadUser(t, ctx, 2)
contexttest.LoadRepo(t, ctx, 1)
- ctx.SetPathParam(":id", "1")
- ctx.SetPathParam(":columnID", "2")
+ ctx.SetPathParam("id", "1")
+ ctx.SetPathParam("columnID", "2")
project, column := checkProjectColumnChangePermissions(ctx)
assert.NotNil(t, project)
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index 0948282ca2..9f3d1c1b7c 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -108,7 +108,7 @@ func getRepository(ctx *context.Context, repoID int64) *repo_model.Repository {
}
func getPullInfo(ctx *context.Context) (issue *issues_model.Issue, ok bool) {
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound("GetIssueByIndex", err)
@@ -1544,7 +1544,7 @@ func DownloadPullPatch(ctx *context.Context) {
// DownloadPullDiffOrPatch render a pull's raw diff or patch
func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) {
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
+ pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
@@ -1637,7 +1637,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
func SetAllowEdits(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.UpdateAllowEditsForm)
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
+ pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 6df7d78f7a..85a745acbd 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -311,7 +311,7 @@ const (
// Action response for actions to a repository
func Action(ctx *context.Context) {
var err error
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "watch":
err = repo_model.WatchRepo(ctx, ctx.Doer, ctx.Repo.Repository, true)
case "unwatch":
@@ -339,12 +339,12 @@ func Action(ctx *context.Context) {
if errors.Is(err, user_model.ErrBlockedUser) {
ctx.Flash.Error(ctx.Tr("repo.action.blocked_user"))
} else {
- ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam(":action")), err)
+ ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam("action")), err)
return
}
}
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "watch", "unwatch":
ctx.Data["IsWatchingRepo"] = repo_model.IsWatching(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
case "star", "unstar":
@@ -354,17 +354,17 @@ func Action(ctx *context.Context) {
// see the `hx-trigger="refreshUserCards ..."` comments in tmpl
ctx.RespHeader().Add("hx-trigger", "refreshUserCards")
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "watch", "unwatch", "star", "unstar":
// we have to reload the repository because NumStars or NumWatching (used in the templates) has just changed
ctx.Data["Repository"], err = repo_model.GetRepositoryByName(ctx, ctx.Repo.Repository.OwnerID, ctx.Repo.Repository.Name)
if err != nil {
- ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam(":action")), err)
+ ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam("action")), err)
return
}
}
- switch ctx.PathParam(":action") {
+ switch ctx.PathParam("action") {
case "watch", "unwatch":
ctx.HTML(http.StatusOK, tplWatchUnwatch)
return
diff --git a/routers/web/repo/setting/git_hooks.go b/routers/web/repo/setting/git_hooks.go
index 2e9caa4c86..1d92211303 100644
--- a/routers/web/repo/setting/git_hooks.go
+++ b/routers/web/repo/setting/git_hooks.go
@@ -30,7 +30,7 @@ func GitHooksEdit(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings.githooks")
ctx.Data["PageIsSettingsGitHooks"] = true
- name := ctx.PathParam(":name")
+ name := ctx.PathParam("name")
hook, err := ctx.Repo.GitRepo.GetHook(name)
if err != nil {
if err == git.ErrNotValidHook {
@@ -46,7 +46,7 @@ func GitHooksEdit(ctx *context.Context) {
// GitHooksEditPost response for editing a git hook of a repository
func GitHooksEditPost(ctx *context.Context) {
- name := ctx.PathParam(":name")
+ name := ctx.PathParam("name")
hook, err := ctx.Repo.GitRepo.GetHook(name)
if err != nil {
if err == git.ErrNotValidHook {
diff --git a/routers/web/repo/setting/protected_tag.go b/routers/web/repo/setting/protected_tag.go
index 1c24c8a7ba..1730ad4a8b 100644
--- a/routers/web/repo/setting/protected_tag.go
+++ b/routers/web/repo/setting/protected_tag.go
@@ -170,7 +170,7 @@ func setTagsContext(ctx *context.Context) error {
func selectProtectedTagByContext(ctx *context.Context) *git_model.ProtectedTag {
id := ctx.FormInt64("id")
if id == 0 {
- id = ctx.PathParamInt64(":id")
+ id = ctx.PathParamInt64("id")
}
tag, err := git_model.GetProtectedTagByID(ctx, id)
diff --git a/routers/web/repo/setting/runners.go b/routers/web/repo/setting/runners.go
index ec037baec1..94f2ae7a0c 100644
--- a/routers/web/repo/setting/runners.go
+++ b/routers/web/repo/setting/runners.go
@@ -147,7 +147,7 @@ func RunnersEdit(ctx *context.Context) {
}
actions_shared.RunnerDetails(ctx, page,
- ctx.PathParamInt64(":runnerid"), rCtx.OwnerID, rCtx.RepoID,
+ ctx.PathParamInt64("runnerid"), rCtx.OwnerID, rCtx.RepoID,
)
ctx.HTML(http.StatusOK, rCtx.RunnerEditTemplate)
}
@@ -158,9 +158,9 @@ func RunnersEditPost(ctx *context.Context) {
ctx.ServerError("getRunnersCtx", err)
return
}
- actions_shared.RunnerDetailsEditPost(ctx, ctx.PathParamInt64(":runnerid"),
+ actions_shared.RunnerDetailsEditPost(ctx, ctx.PathParamInt64("runnerid"),
rCtx.OwnerID, rCtx.RepoID,
- rCtx.RedirectLink+url.PathEscape(ctx.PathParam(":runnerid")))
+ rCtx.RedirectLink+url.PathEscape(ctx.PathParam("runnerid")))
}
func ResetRunnerRegistrationToken(ctx *context.Context) {
@@ -179,7 +179,7 @@ func RunnerDeletePost(ctx *context.Context) {
ctx.ServerError("getRunnersCtx", err)
return
}
- actions_shared.RunnerDeletePost(ctx, ctx.PathParamInt64(":runnerid"), rCtx.RedirectLink, rCtx.RedirectLink+url.PathEscape(ctx.PathParam(":runnerid")))
+ actions_shared.RunnerDeletePost(ctx, ctx.PathParamInt64("runnerid"), rCtx.RedirectLink, rCtx.RedirectLink+url.PathEscape(ctx.PathParam("runnerid")))
}
func RedirectToDefaultSetting(ctx *context.Context) {
diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go
index bcf8a7eac0..1b0ba83af4 100644
--- a/routers/web/repo/setting/webhook.go
+++ b/routers/web/repo/setting/webhook.go
@@ -99,9 +99,9 @@ func getOwnerRepoCtx(ctx *context.Context) (*ownerRepoCtx, error) {
if ctx.Data["PageIsAdmin"] == true {
return &ownerRepoCtx{
IsAdmin: true,
- IsSystemWebhook: ctx.PathParam(":configType") == "system-hooks",
+ IsSystemWebhook: ctx.PathParam("configType") == "system-hooks",
Link: path.Join(setting.AppSubURL, "/-/admin/hooks"),
- LinkNew: path.Join(setting.AppSubURL, "/-/admin/", ctx.PathParam(":configType")),
+ LinkNew: path.Join(setting.AppSubURL, "/-/admin/", ctx.PathParam("configType")),
NewTemplate: tplAdminHookNew,
}, nil
}
@@ -110,7 +110,7 @@ func getOwnerRepoCtx(ctx *context.Context) (*ownerRepoCtx, error) {
}
func checkHookType(ctx *context.Context) string {
- hookType := strings.ToLower(ctx.PathParam(":type"))
+ hookType := strings.ToLower(ctx.PathParam("type"))
if !util.SliceContainsString(setting.Webhook.Types, hookType, true) {
ctx.NotFound("checkHookType", nil)
return ""
@@ -592,11 +592,11 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) {
var w *webhook.Webhook
if orCtx.RepoID > 0 {
- w, err = webhook.GetWebhookByRepoID(ctx, orCtx.RepoID, ctx.PathParamInt64(":id"))
+ w, err = webhook.GetWebhookByRepoID(ctx, orCtx.RepoID, ctx.PathParamInt64("id"))
} else if orCtx.OwnerID > 0 {
- w, err = webhook.GetWebhookByOwnerID(ctx, orCtx.OwnerID, ctx.PathParamInt64(":id"))
+ w, err = webhook.GetWebhookByOwnerID(ctx, orCtx.OwnerID, ctx.PathParamInt64("id"))
} else if orCtx.IsAdmin {
- w, err = webhook.GetSystemOrDefaultWebhook(ctx, ctx.PathParamInt64(":id"))
+ w, err = webhook.GetSystemOrDefaultWebhook(ctx, ctx.PathParamInt64("id"))
}
if err != nil || w == nil {
if webhook.IsErrWebhookNotExist(err) {
@@ -645,7 +645,7 @@ func WebHooksEdit(ctx *context.Context) {
// TestWebhook test if web hook is work fine
func TestWebhook(ctx *context.Context) {
- hookID := ctx.PathParamInt64(":id")
+ hookID := ctx.PathParamInt64("id")
w, err := webhook.GetWebhookByRepoID(ctx, ctx.Repo.Repository.ID, hookID)
if err != nil {
ctx.Flash.Error("GetWebhookByRepoID: " + err.Error())
@@ -706,7 +706,7 @@ func TestWebhook(ctx *context.Context) {
// ReplayWebhook replays a webhook
func ReplayWebhook(ctx *context.Context) {
- hookTaskUUID := ctx.PathParam(":uuid")
+ hookTaskUUID := ctx.PathParam("uuid")
orCtx, w := checkWebhook(ctx)
if ctx.Written() {
diff --git a/routers/web/repo/view_home.go b/routers/web/repo/view_home.go
index b318c4a621..70ba07f9a8 100644
--- a/routers/web/repo/view_home.go
+++ b/routers/web/repo/view_home.go
@@ -276,7 +276,7 @@ func prepareToRenderDirOrFile(entry *git.TreeEntry) func(ctx *context.Context) {
func handleRepoHomeFeed(ctx *context.Context) bool {
if setting.Other.EnableFeed {
- isFeed, _, showFeedType := feed.GetFeedType(ctx.PathParam(":reponame"), ctx.Req)
+ isFeed, _, showFeedType := feed.GetFeedType(ctx.PathParam("reponame"), ctx.Req)
if isFeed {
switch {
case ctx.Link == fmt.Sprintf("%s.%s", ctx.Repo.RepoLink, showFeedType):
diff --git a/routers/web/shared/actions/variables.go b/routers/web/shared/actions/variables.go
index 5c5768243a..f895475748 100644
--- a/routers/web/shared/actions/variables.go
+++ b/routers/web/shared/actions/variables.go
@@ -40,7 +40,7 @@ func CreateVariable(ctx *context.Context, ownerID, repoID int64, redirectURL str
}
func UpdateVariable(ctx *context.Context, redirectURL string) {
- id := ctx.PathParamInt64(":variable_id")
+ id := ctx.PathParamInt64("variable_id")
form := web.GetForm(ctx).(*forms.EditVariableForm)
if ok, err := actions_service.UpdateVariable(ctx, id, form.Name, form.Data); err != nil || !ok {
@@ -53,7 +53,7 @@ func UpdateVariable(ctx *context.Context, redirectURL string) {
}
func DeleteVariable(ctx *context.Context, redirectURL string) {
- id := ctx.PathParamInt64(":variable_id")
+ id := ctx.PathParamInt64("variable_id")
if err := actions_service.DeleteVariableByID(ctx, id); err != nil {
log.Error("Delete variable [%d] failed: %v", id, err)
diff --git a/routers/web/shared/project/column.go b/routers/web/shared/project/column.go
index ba1f527bea..141c80716f 100644
--- a/routers/web/shared/project/column.go
+++ b/routers/web/shared/project/column.go
@@ -11,7 +11,7 @@ import (
// MoveColumns moves or keeps columns in a project and sorts them inside that project
func MoveColumns(ctx *context.Context) {
- project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
diff --git a/routers/web/user/avatar.go b/routers/web/user/avatar.go
index 7000e25778..f77bd602b3 100644
--- a/routers/web/user/avatar.go
+++ b/routers/web/user/avatar.go
@@ -23,8 +23,8 @@ func cacheableRedirect(ctx *context.Context, location string) {
// AvatarByUserName redirect browser to user avatar of requested size
func AvatarByUserName(ctx *context.Context) {
- userName := ctx.PathParam(":username")
- size := int(ctx.PathParamInt64(":size"))
+ userName := ctx.PathParam("username")
+ size := int(ctx.PathParamInt64("size"))
var user *user_model.User
if strings.ToLower(userName) != user_model.GhostUserLowerName {
@@ -46,7 +46,7 @@ func AvatarByUserName(ctx *context.Context) {
// AvatarByEmailHash redirects the browser to the email avatar link
func AvatarByEmailHash(ctx *context.Context) {
- hash := ctx.PathParam(":hash")
+ hash := ctx.PathParam("hash")
email, err := avatars.GetEmailForHash(ctx, hash)
if err != nil {
ctx.ServerError("invalid avatar hash: "+hash, err)
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index e118aa051e..b5d3a7294b 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -56,7 +56,7 @@ const (
// getDashboardContextUser finds out which context user dashboard is being viewed as .
func getDashboardContextUser(ctx *context.Context) *user_model.User {
ctxUser := ctx.Doer
- orgName := ctx.PathParam(":org")
+ orgName := ctx.PathParam("org")
if len(orgName) > 0 {
ctxUser = ctx.Org.Organization.AsUser()
ctx.Data["Teams"] = ctx.Org.Teams
diff --git a/routers/web/user/package.go b/routers/web/user/package.go
index d5aac513b6..8d78da7c5a 100644
--- a/routers/web/user/package.go
+++ b/routers/web/user/package.go
@@ -502,7 +502,7 @@ func PackageSettingsPost(ctx *context.Context) {
// DownloadPackageFile serves the content of a package file
func DownloadPackageFile(ctx *context.Context) {
- pf, err := packages_model.GetFileForVersionByID(ctx, ctx.Package.Descriptor.Version.ID, ctx.PathParamInt64(":fileid"))
+ pf, err := packages_model.GetFileForVersionByID(ctx, ctx.Package.Descriptor.Version.ID, ctx.PathParamInt64("fileid"))
if err != nil {
if err == packages_model.ErrPackageFileNotExist {
ctx.NotFound("", err)