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.
This commit is contained in:
parent
b8b690feb9
commit
2a828e2798
102 changed files with 461 additions and 429 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue