summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/templates/helper.go68
-rw-r--r--modules/templates/helper_test.go4
-rw-r--r--modules/templates/mailer.go2
-rw-r--r--modules/templates/util_misc.go18
-rw-r--r--modules/templates/util_render.go40
-rw-r--r--modules/templates/util_render_test.go8
-rw-r--r--modules/web/route.go68
-rw-r--r--modules/web/route_test.go10
-rw-r--r--modules/web/routemock.go8
-rw-r--r--modules/web/routemock_test.go4
-rw-r--r--routers/api/actions/actions.go4
-rw-r--r--routers/api/actions/artifacts.go6
-rw-r--r--routers/api/actions/artifacts_utils.go4
-rw-r--r--routers/api/actions/artifactsv4.go4
-rw-r--r--routers/api/packages/alpine/alpine.go18
-rw-r--r--routers/api/packages/api.go80
-rw-r--r--routers/api/packages/cargo/cargo.go10
-rw-r--r--routers/api/packages/chef/chef.go14
-rw-r--r--routers/api/packages/composer/composer.go10
-rw-r--r--routers/api/packages/conan/conan.go18
-rw-r--r--routers/api/packages/conda/conda.go16
-rw-r--r--routers/api/packages/container/container.go34
-rw-r--r--routers/api/packages/cran/cran.go16
-rw-r--r--routers/api/packages/debian/debian.go34
-rw-r--r--routers/api/packages/generic/generic.go20
-rw-r--r--routers/api/packages/goproxy/goproxy.go8
-rw-r--r--routers/api/packages/helm/helm.go4
-rw-r--r--routers/api/packages/maven/maven.go2
-rw-r--r--routers/api/packages/npm/npm.go16
-rw-r--r--routers/api/packages/nuget/nuget.go28
-rw-r--r--routers/api/packages/pub/pub.go14
-rw-r--r--routers/api/packages/pypi/pypi.go8
-rw-r--r--routers/api/packages/rpm/rpm.go26
-rw-r--r--routers/api/packages/rubygems/rubygems.go6
-rw-r--r--routers/api/packages/swift/swift.go22
-rw-r--r--routers/api/packages/vagrant/vagrant.go16
-rw-r--r--routers/api/v1/admin/adopt.go8
-rw-r--r--routers/api/v1/admin/cron.go2
-rw-r--r--routers/api/v1/admin/email.go4
-rw-r--r--routers/api/v1/admin/hooks.go6
-rw-r--r--routers/api/v1/admin/user.go2
-rw-r--r--routers/api/v1/api.go18
-rw-r--r--routers/api/v1/misc/gitignore.go2
-rw-r--r--routers/api/v1/misc/label_templates.go2
-rw-r--r--routers/api/v1/misc/licenses.go2
-rw-r--r--routers/api/v1/notify/threads.go2
-rw-r--r--routers/api/v1/org/action.go14
-rw-r--r--routers/api/v1/org/hook.go6
-rw-r--r--routers/api/v1/org/label.go6
-rw-r--r--routers/api/v1/org/team.go4
-rw-r--r--routers/api/v1/repo/action.go14
-rw-r--r--routers/api/v1/repo/blob.go2
-rw-r--r--routers/api/v1/repo/branch.go10
-rw-r--r--routers/api/v1/repo/collaborators.go10
-rw-r--r--routers/api/v1/repo/commits.go8
-rw-r--r--routers/api/v1/repo/compare.go2
-rw-r--r--routers/api/v1/repo/file.go12
-rw-r--r--routers/api/v1/repo/git_hook.go6
-rw-r--r--routers/api/v1/repo/git_ref.go2
-rw-r--r--routers/api/v1/repo/hook.go8
-rw-r--r--routers/api/v1/repo/hook_test.go2
-rw-r--r--routers/api/v1/repo/issue.go8
-rw-r--r--routers/api/v1/repo/issue_attachment.go4
-rw-r--r--routers/api/v1/repo/issue_comment.go12
-rw-r--r--routers/api/v1/repo/issue_comment_attachment.go4
-rw-r--r--routers/api/v1/repo/issue_dependency.go4
-rw-r--r--routers/api/v1/repo/issue_label.go10
-rw-r--r--routers/api/v1/repo/issue_pin.go8
-rw-r--r--routers/api/v1/repo/issue_reaction.go8
-rw-r--r--routers/api/v1/repo/issue_stopwatch.go2
-rw-r--r--routers/api/v1/repo/issue_subscription.go8
-rw-r--r--routers/api/v1/repo/issue_tracked_time.go12
-rw-r--r--routers/api/v1/repo/key.go4
-rw-r--r--routers/api/v1/repo/label.go6
-rw-r--r--routers/api/v1/repo/milestone.go2
-rw-r--r--routers/api/v1/repo/mirror.go4
-rw-r--r--routers/api/v1/repo/notes.go2
-rw-r--r--routers/api/v1/repo/pull.go24
-rw-r--r--routers/api/v1/repo/pull_review.go10
-rw-r--r--routers/api/v1/repo/release.go6
-rw-r--r--routers/api/v1/repo/release_attachment.go16
-rw-r--r--routers/api/v1/repo/release_tags.go4
-rw-r--r--routers/api/v1/repo/repo.go4
-rw-r--r--routers/api/v1/repo/status.go8
-rw-r--r--routers/api/v1/repo/tag.go12
-rw-r--r--routers/api/v1/repo/teams.go2
-rw-r--r--routers/api/v1/repo/topic.go4
-rw-r--r--routers/api/v1/repo/tree.go2
-rw-r--r--routers/api/v1/shared/block.go6
-rw-r--r--routers/api/v1/user/action.go14
-rw-r--r--routers/api/v1/user/app.go8
-rw-r--r--routers/api/v1/user/gpg_key.go4
-rw-r--r--routers/api/v1/user/helper.go2
-rw-r--r--routers/api/v1/user/hook.go6
-rw-r--r--routers/api/v1/user/key.go6
-rw-r--r--routers/api/v1/user/user.go2
-rw-r--r--routers/init.go4
-rw-r--r--routers/install/routes.go6
-rw-r--r--routers/private/default_branch.go6
-rw-r--r--routers/private/hook_post_receive.go4
-rw-r--r--routers/private/internal.go4
-rw-r--r--routers/private/internal_repo.go4
-rw-r--r--routers/private/key.go4
-rw-r--r--routers/private/manager.go4
-rw-r--r--routers/private/serv.go8
-rw-r--r--routers/web/admin/auths.go8
-rw-r--r--routers/web/admin/queue.go6
-rw-r--r--routers/web/admin/stacktrace.go2
-rw-r--r--routers/web/admin/users.go16
-rw-r--r--routers/web/auth/auth_test.go2
-rw-r--r--routers/web/auth/oauth.go4
-rw-r--r--routers/web/devtest/devtest.go2
-rw-r--r--routers/web/explore/repo.go4
-rw-r--r--routers/web/explore/user.go4
-rw-r--r--routers/web/feed/render.go2
-rw-r--r--routers/web/githttp.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.go16
-rw-r--r--routers/web/repo/actions/badge.go2
-rw-r--r--routers/web/repo/actions/view.go30
-rw-r--r--routers/web/repo/activity.go4
-rw-r--r--routers/web/repo/attachment.go2
-rw-r--r--routers/web/repo/cherry_pick.go12
-rw-r--r--routers/web/repo/commit.go12
-rw-r--r--routers/web/repo/compare.go6
-rw-r--r--routers/web/repo/download.go4
-rw-r--r--routers/web/repo/editor_test.go4
-rw-r--r--routers/web/repo/find.go2
-rw-r--r--routers/web/repo/githttp.go12
-rw-r--r--routers/web/repo/issue.go34
-rw-r--r--routers/web/repo/issue_dependency.go4
-rw-r--r--routers/web/repo/issue_pin.go2
-rw-r--r--routers/web/repo/issue_timetrack.go2
-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.go12
-rw-r--r--routers/web/repo/release.go6
-rw-r--r--routers/web/repo/repo.go20
-rw-r--r--routers/web/repo/setting/git_hooks.go4
-rw-r--r--routers/web/repo/setting/lfs.go6
-rw-r--r--routers/web/repo/setting/protected_branch.go2
-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.go2
-rw-r--r--routers/web/repo/wiki_test.go10
-rw-r--r--routers/web/shared/actions/variables.go4
-rw-r--r--routers/web/shared/packages/packages.go2
-rw-r--r--routers/web/shared/project/column.go2
-rw-r--r--routers/web/user/avatar.go6
-rw-r--r--routers/web/user/home.go6
-rw-r--r--routers/web/user/home_test.go6
-rw-r--r--routers/web/user/package.go6
-rw-r--r--routers/web/user/setting/oauth2_common.go10
-rw-r--r--routers/web/user/task.go4
-rw-r--r--routers/web/web.go8
-rw-r--r--services/context/api.go4
-rw-r--r--services/context/base.go14
-rw-r--r--services/context/org.go4
-rw-r--r--services/context/package.go6
-rw-r--r--services/context/repo.go20
-rw-r--r--services/context/upload/upload.go4
-rw-r--r--services/context/user.go4
-rw-r--r--services/lfs/locks.go16
-rw-r--r--services/lfs/server.go12
-rw-r--r--services/repository/files/content_test.go18
-rw-r--r--services/repository/files/diff_test.go4
-rw-r--r--services/repository/files/file_test.go2
-rw-r--r--services/repository/files/tree_test.go6
-rw-r--r--services/wiki/wiki_path.go2
-rw-r--r--tests/e2e/e2e_test.go2
-rw-r--r--tests/integration/integration_test.go2
-rw-r--r--tests/integration/repofiles_change_test.go14
177 files changed, 837 insertions, 837 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 330cbf8908..5f73e6b278 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -36,16 +36,16 @@ func NewFuncMap() template.FuncMap {
// -----------------------------------------------------------------
// html/template related functions
"dict": dict, // it's lowercase because this name has been widely used. Our other functions should have uppercase names.
- "Iif": Iif,
- "Eval": Eval,
- "SafeHTML": SafeHTML,
+ "Iif": iif,
+ "Eval": evalTokens,
+ "SafeHTML": safeHTML,
"HTMLFormat": HTMLFormat,
- "HTMLEscape": HTMLEscape,
- "QueryEscape": QueryEscape,
- "JSEscape": JSEscapeSafe,
+ "HTMLEscape": htmlEscape,
+ "QueryEscape": queryEscape,
+ "JSEscape": jsEscapeSafe,
"SanitizeHTML": SanitizeHTML,
"URLJoin": util.URLJoin,
- "DotEscape": DotEscape,
+ "DotEscape": dotEscape,
"PathEscape": url.PathEscape,
"PathEscapeSegments": util.PathEscapeSegments,
@@ -59,9 +59,9 @@ func NewFuncMap() template.FuncMap {
// svg / avatar / icon / color
"svg": svg.RenderHTML,
"EntryIcon": base.EntryIcon,
- "MigrationIcon": MigrationIcon,
- "ActionIcon": ActionIcon,
- "SortArrow": SortArrow,
+ "MigrationIcon": migrationIcon,
+ "ActionIcon": actionIcon,
+ "SortArrow": sortArrow,
"ContrastColor": util.ContrastColor,
// -----------------------------------------------------------------
@@ -139,7 +139,7 @@ func NewFuncMap() template.FuncMap {
"DisableImportLocal": func() bool {
return !setting.ImportLocalPaths
},
- "UserThemeName": UserThemeName,
+ "UserThemeName": userThemeName,
"NotificationSettings": func() map[string]any {
return map[string]any{
"MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond),
@@ -155,28 +155,28 @@ func NewFuncMap() template.FuncMap {
// -----------------------------------------------------------------
// render
"RenderCommitMessage": RenderCommitMessage,
- "RenderCommitMessageLinkSubject": RenderCommitMessageLinkSubject,
+ "RenderCommitMessageLinkSubject": renderCommitMessageLinkSubject,
- "RenderCommitBody": RenderCommitBody,
- "RenderCodeBlock": RenderCodeBlock,
- "RenderIssueTitle": RenderIssueTitle,
- "RenderEmoji": RenderEmoji,
- "ReactionToEmoji": ReactionToEmoji,
+ "RenderCommitBody": renderCommitBody,
+ "RenderCodeBlock": renderCodeBlock,
+ "RenderIssueTitle": renderIssueTitle,
+ "RenderEmoji": renderEmoji,
+ "ReactionToEmoji": reactionToEmoji,
"RenderMarkdownToHtml": RenderMarkdownToHtml,
- "RenderLabel": RenderLabel,
+ "RenderLabel": renderLabel,
"RenderLabels": RenderLabels,
// -----------------------------------------------------------------
// misc
"ShortSha": base.ShortSha,
"ActionContent2Commits": ActionContent2Commits,
- "IsMultilineCommitMessage": IsMultilineCommitMessage,
+ "IsMultilineCommitMessage": isMultilineCommitMessage,
"CommentMustAsDiff": gitdiff.CommentMustAsDiff,
"MirrorRemoteAddress": mirrorRemoteAddress,
- "FilenameIsImage": FilenameIsImage,
- "TabSizeClass": TabSizeClass,
+ "FilenameIsImage": filenameIsImage,
+ "TabSizeClass": tabSizeClass,
}
}
@@ -197,8 +197,8 @@ func HTMLFormat(s string, rawArgs ...any) template.HTML {
return template.HTML(fmt.Sprintf(s, args...))
}
-// SafeHTML render raw as HTML
-func SafeHTML(s any) template.HTML {
+// safeHTML render raw as HTML
+func safeHTML(s any) template.HTML {
switch v := s.(type) {
case string:
return template.HTML(v)
@@ -213,7 +213,7 @@ func SanitizeHTML(s string) template.HTML {
return template.HTML(markup.Sanitize(s))
}
-func HTMLEscape(s any) template.HTML {
+func htmlEscape(s any) template.HTML {
switch v := s.(type) {
case string:
return template.HTML(html.EscapeString(v))
@@ -223,22 +223,22 @@ func HTMLEscape(s any) template.HTML {
panic(fmt.Sprintf("unexpected type %T", s))
}
-func JSEscapeSafe(s string) template.HTML {
+func jsEscapeSafe(s string) template.HTML {
return template.HTML(template.JSEscapeString(s))
}
-func QueryEscape(s string) template.URL {
+func queryEscape(s string) template.URL {
return template.URL(url.QueryEscape(s))
}
-// DotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent autolinkers from detecting these as urls
-func DotEscape(raw string) string {
+// dotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent auto-linkers from detecting these as urls
+func dotEscape(raw string) string {
return strings.ReplaceAll(raw, ".", "\u200d.\u200d")
}
-// Iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version,
-// and it could be simply used as "{{Iif expr trueVal}}" (omit the falseVal).
-func Iif(condition any, vals ...any) any {
+// iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version,
+// and it could be simply used as "{{iif expr trueVal}}" (omit the falseVal).
+func iif(condition any, vals ...any) any {
if isTemplateTruthy(condition) {
return vals[0]
} else if len(vals) > 1 {
@@ -273,19 +273,19 @@ func isTemplateTruthy(v any) bool {
}
}
-// Eval the expression and return the result, see the comment of eval.Expr for details.
+// evalTokens evaluates the expression by tokens and returns the result, see the comment of eval.Expr for details.
// To use this helper function in templates, pass each token as a separate parameter.
//
// {{ $int64 := Eval $var "+" 1 }}
// {{ $float64 := Eval $var "+" 1.0 }}
//
// Golang's template supports comparable int types, so the int64 result can be used in later statements like {{if lt $int64 10}}
-func Eval(tokens ...any) (any, error) {
+func evalTokens(tokens ...any) (any, error) {
n, err := eval.Expr(tokens...)
return n.Value, err
}
-func UserThemeName(user *user_model.User) string {
+func userThemeName(user *user_model.User) string {
if user == nil || user.Theme == "" {
return setting.UI.DefaultTheme
}
diff --git a/modules/templates/helper_test.go b/modules/templates/helper_test.go
index ea5da7be80..b9fabb7016 100644
--- a/modules/templates/helper_test.go
+++ b/modules/templates/helper_test.go
@@ -58,7 +58,7 @@ func TestSubjectBodySeparator(t *testing.T) {
}
func TestJSEscapeSafe(t *testing.T) {
- assert.EqualValues(t, `\u0026\u003C\u003E\'\"`, JSEscapeSafe(`&<>'"`))
+ assert.EqualValues(t, `\u0026\u003C\u003E\'\"`, jsEscapeSafe(`&<>'"`))
}
func TestHTMLFormat(t *testing.T) {
@@ -71,7 +71,7 @@ func TestSanitizeHTML(t *testing.T) {
func TestTemplateTruthy(t *testing.T) {
tmpl := template.New("test")
- tmpl.Funcs(template.FuncMap{"Iif": Iif})
+ tmpl.Funcs(template.FuncMap{"Iif": iif})
template.Must(tmpl.Parse(`{{if .Value}}true{{else}}false{{end}}:{{Iif .Value "true" "false"}}`))
cases := []any{
diff --git a/modules/templates/mailer.go b/modules/templates/mailer.go
index 7c97e1ea89..ace81bf4a5 100644
--- a/modules/templates/mailer.go
+++ b/modules/templates/mailer.go
@@ -22,7 +22,7 @@ var mailSubjectSplit = regexp.MustCompile(`(?m)^-{3,}\s*$`)
func mailSubjectTextFuncMap() texttmpl.FuncMap {
return texttmpl.FuncMap{
"dict": dict,
- "Eval": Eval,
+ "Eval": evalTokens,
"EllipsisString": base.EllipsisString,
"AppName": func() string {
diff --git a/modules/templates/util_misc.go b/modules/templates/util_misc.go
index 774385483b..d645fa013e 100644
--- a/modules/templates/util_misc.go
+++ b/modules/templates/util_misc.go
@@ -24,7 +24,7 @@ import (
"github.com/editorconfig/editorconfig-core-go/v2"
)
-func SortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML {
+func sortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML {
// if needed
if len(normSort) == 0 || len(urlSort) == 0 {
return ""
@@ -50,8 +50,8 @@ func SortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML
return ""
}
-// IsMultilineCommitMessage checks to see if a commit message contains multiple lines.
-func IsMultilineCommitMessage(msg string) bool {
+// isMultilineCommitMessage checks to see if a commit message contains multiple lines.
+func isMultilineCommitMessage(msg string) bool {
return strings.Count(strings.TrimSpace(msg), "\n") >= 1
}
@@ -69,8 +69,8 @@ type Actioner interface {
GetIssueInfos() []string
}
-// ActionIcon accepts an action operation type and returns an icon class name.
-func ActionIcon(opType activities_model.ActionType) string {
+// actionIcon accepts an action operation type and returns an icon class name.
+func actionIcon(opType activities_model.ActionType) string {
switch opType {
case activities_model.ActionCreateRepo, activities_model.ActionTransferRepo, activities_model.ActionRenameRepo:
return "repo"
@@ -126,8 +126,8 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits {
return push
}
-// MigrationIcon returns a SVG name matching the service an issue/comment was migrated from
-func MigrationIcon(hostname string) string {
+// migrationIcon returns a SVG name matching the service an issue/comment was migrated from
+func migrationIcon(hostname string) string {
switch hostname {
case "github.com":
return "octicon-mark-github"
@@ -177,12 +177,12 @@ func mirrorRemoteAddress(ctx context.Context, m *repo_model.Repository, remoteNa
return ret
}
-func FilenameIsImage(filename string) bool {
+func filenameIsImage(filename string) bool {
mimeType := mime.TypeByExtension(filepath.Ext(filename))
return strings.HasPrefix(mimeType, "image/")
}
-func TabSizeClass(ec *editorconfig.Editorconfig, filename string) string {
+func tabSizeClass(ec *editorconfig.Editorconfig, filename string) string {
if ec != nil {
def, err := ec.GetDefinitionForFilename(filename)
if err == nil && def.TabWidth >= 1 && def.TabWidth <= 16 {
diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go
index b15de6521d..6eee007f34 100644
--- a/modules/templates/util_render.go
+++ b/modules/templates/util_render.go
@@ -41,12 +41,12 @@ func RenderCommitMessage(ctx context.Context, msg string, metas map[string]strin
if len(msgLines) == 0 {
return template.HTML("")
}
- return RenderCodeBlock(template.HTML(msgLines[0]))
+ return renderCodeBlock(template.HTML(msgLines[0]))
}
-// RenderCommitMessageLinkSubject renders commit message as a XSS-safe link to
+// renderCommitMessageLinkSubject renders commit message as a XSS-safe link to
// the provided default url, handling for special links without email to links.
-func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string, metas map[string]string) template.HTML {
+func renderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string, metas map[string]string) template.HTML {
msgLine := strings.TrimLeftFunc(msg, unicode.IsSpace)
lineEnd := strings.IndexByte(msgLine, '\n')
if lineEnd > 0 {
@@ -68,11 +68,11 @@ func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string,
log.Error("RenderCommitMessageSubject: %v", err)
return template.HTML("")
}
- return RenderCodeBlock(template.HTML(renderedMessage))
+ return renderCodeBlock(template.HTML(renderedMessage))
}
-// RenderCommitBody extracts the body of a commit message without its title.
-func RenderCommitBody(ctx context.Context, msg string, metas map[string]string) template.HTML {
+// renderCommitBody extracts the body of a commit message without its title.
+func renderCommitBody(ctx context.Context, msg string, metas map[string]string) template.HTML {
msgLine := strings.TrimSpace(msg)
lineEnd := strings.IndexByte(msgLine, '\n')
if lineEnd > 0 {
@@ -99,14 +99,14 @@ func RenderCommitBody(ctx context.Context, msg string, metas map[string]string)
// Match text that is between back ticks.
var codeMatcher = regexp.MustCompile("`([^`]+)`")
-// RenderCodeBlock renders "`…`" as highlighted "<code>" block, intended for issue and PR titles
-func RenderCodeBlock(htmlEscapedTextToRender template.HTML) template.HTML {
+// renderCodeBlock renders "`…`" as highlighted "<code>" block, intended for issue and PR titles
+func renderCodeBlock(htmlEscapedTextToRender template.HTML) template.HTML {
htmlWithCodeTags := codeMatcher.ReplaceAllString(string(htmlEscapedTextToRender), `<code class="inline-code-block">$1</code>`) // replace with HTML <code> tags
return template.HTML(htmlWithCodeTags)
}
-// RenderIssueTitle renders issue/pull title with defined post processors
-func RenderIssueTitle(ctx context.Context, text string, metas map[string]string) template.HTML {
+// renderIssueTitle renders issue/pull title with defined post processors
+func renderIssueTitle(ctx context.Context, text string, metas map[string]string) template.HTML {
renderedText, err := markup.RenderIssueTitle(&markup.RenderContext{
Ctx: ctx,
Metas: metas,
@@ -118,9 +118,9 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string)
return template.HTML(renderedText)
}
-// RenderLabel renders a label
+// renderLabel renders a label
// locale is needed due to an import cycle with our context providing the `Tr` function
-func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML {
+func renderLabel(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML {
var extraCSSClasses string
textColor := util.ContrastColor(label.Color)
labelScope := label.ExclusiveScope()
@@ -134,12 +134,12 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m
if labelScope == "" {
// Regular label
return HTMLFormat(`<div class="ui label %s" style="color: %s !important; background-color: %s !important;" data-tooltip-content title="%s">%s</div>`,
- extraCSSClasses, textColor, label.Color, descriptionText, RenderEmoji(ctx, label.Name))
+ extraCSSClasses, textColor, label.Color, descriptionText, renderEmoji(ctx, label.Name))
}
// Scoped label
- scopeHTML := RenderEmoji(ctx, labelScope)
- itemHTML := RenderEmoji(ctx, label.Name[len(labelScope)+1:])
+ scopeHTML := renderEmoji(ctx, labelScope)
+ itemHTML := renderEmoji(ctx, label.Name[len(labelScope)+1:])
// Make scope and item background colors slightly darker and lighter respectively.
// More contrast needed with higher luminance, empirically tweaked.
@@ -176,8 +176,8 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m
textColor, itemColor, itemHTML)
}
-// RenderEmoji renders html text with emoji post processors
-func RenderEmoji(ctx context.Context, text string) template.HTML {
+// renderEmoji renders html text with emoji post processors
+func renderEmoji(ctx context.Context, text string) template.HTML {
renderedText, err := markup.RenderEmoji(&markup.RenderContext{Ctx: ctx},
template.HTMLEscapeString(text))
if err != nil {
@@ -187,8 +187,8 @@ func RenderEmoji(ctx context.Context, text string) template.HTML {
return template.HTML(renderedText)
}
-// ReactionToEmoji renders emoji for use in reactions
-func ReactionToEmoji(reaction string) template.HTML {
+// reactionToEmoji renders emoji for use in reactions
+func reactionToEmoji(reaction string) template.HTML {
val := emoji.FromCode(reaction)
if val != nil {
return template.HTML(val.Emoji)
@@ -220,7 +220,7 @@ func RenderLabels(ctx context.Context, locale translation.Locale, labels []*issu
if label == nil {
continue
}
- htmlCode += fmt.Sprintf(`<a href="%s?labels=%d">%s</a>`, baseLink, label.ID, RenderLabel(ctx, locale, label))
+ htmlCode += fmt.Sprintf(`<a href="%s?labels=%d">%s</a>`, baseLink, label.ID, renderLabel(ctx, locale, label))
}
htmlCode += "</span>"
return template.HTML(htmlCode)
diff --git a/modules/templates/util_render_test.go b/modules/templates/util_render_test.go
index 32e53b5215..ba47c34efc 100644
--- a/modules/templates/util_render_test.go
+++ b/modules/templates/util_render_test.go
@@ -103,7 +103,7 @@ func TestRenderCommitBody(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- assert.Equalf(t, tt.want, RenderCommitBody(tt.args.ctx, tt.args.msg, tt.args.metas), "RenderCommitBody(%v, %v, %v)", tt.args.ctx, tt.args.msg, tt.args.metas)
+ assert.Equalf(t, tt.want, renderCommitBody(tt.args.ctx, tt.args.msg, tt.args.metas), "RenderCommitBody(%v, %v, %v)", tt.args.ctx, tt.args.msg, tt.args.metas)
})
}
@@ -127,7 +127,7 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
<a href="/user13/repo11/issues/123" class="ref-issue">#123</a>
space`
- assert.EqualValues(t, expected, RenderCommitBody(context.Background(), testInput(), testMetas))
+ assert.EqualValues(t, expected, renderCommitBody(context.Background(), testInput(), testMetas))
}
func TestRenderCommitMessage(t *testing.T) {
@@ -139,7 +139,7 @@ func TestRenderCommitMessage(t *testing.T) {
func TestRenderCommitMessageLinkSubject(t *testing.T) {
expected := `<a href="https://example.com/link" class="default-link muted">space </a><a href="/mention-user" class="mention">@mention-user</a>`
- assert.EqualValues(t, expected, RenderCommitMessageLinkSubject(context.Background(), testInput(), "https://example.com/link", testMetas))
+ assert.EqualValues(t, expected, renderCommitMessageLinkSubject(context.Background(), testInput(), "https://example.com/link", testMetas))
}
func TestRenderIssueTitle(t *testing.T) {
@@ -165,7 +165,7 @@ mail@domain.com
space<SPACE><SPACE>
`
expected = strings.ReplaceAll(expected, "<SPACE>", " ")
- assert.EqualValues(t, expected, RenderIssueTitle(context.Background(), testInput(), testMetas))
+ assert.EqualValues(t, expected, renderIssueTitle(context.Background(), testInput(), testMetas))
}
func TestRenderMarkdownToHtml(t *testing.T) {
diff --git a/modules/web/route.go b/modules/web/route.go
index 34290bd8e5..b02f66802e 100644
--- a/modules/web/route.go
+++ b/modules/web/route.go
@@ -36,30 +36,30 @@ func GetForm(dataStore middleware.ContextDataStore) any {
return dataStore.GetData()["__form"]
}
-// Route defines a route based on chi's router
-type Route struct {
- R chi.Router
+// Router defines a route based on chi's router
+type Router struct {
+ chiRouter chi.Router
curGroupPrefix string
curMiddlewares []any
}
-// NewRoute creates a new route
-func NewRoute() *Route {
+// NewRouter creates a new route
+func NewRouter() *Router {
r := chi.NewRouter()
- return &Route{R: r}
+ return &Router{chiRouter: r}
}
// Use supports two middlewares
-func (r *Route) Use(middlewares ...any) {
+func (r *Router) Use(middlewares ...any) {
for _, m := range middlewares {
if m != nil {
- r.R.Use(toHandlerProvider(m))
+ r.chiRouter.Use(toHandlerProvider(m))
}
}
}
// Group mounts a sub-Router along a `pattern` string.
-func (r *Route) Group(pattern string, fn func(), middlewares ...any) {
+func (r *Router) Group(pattern string, fn func(), middlewares ...any) {
previousGroupPrefix := r.curGroupPrefix
previousMiddlewares := r.curMiddlewares
r.curGroupPrefix += pattern
@@ -71,7 +71,7 @@ func (r *Route) Group(pattern string, fn func(), middlewares ...any) {
r.curMiddlewares = previousMiddlewares
}
-func (r *Route) getPattern(pattern string) string {
+func (r *Router) getPattern(pattern string) string {
newPattern := r.curGroupPrefix + pattern
if !strings.HasPrefix(newPattern, "/") {
newPattern = "/" + newPattern
@@ -82,7 +82,7 @@ func (r *Route) getPattern(pattern string) string {
return strings.TrimSuffix(newPattern, "/")
}
-func (r *Route) wrapMiddlewareAndHandler(h []any) ([]func(http.Handler) http.Handler, http.HandlerFunc) {
+func (r *Router) wrapMiddlewareAndHandler(h []any) ([]func(http.Handler) http.Handler, http.HandlerFunc) {
handlerProviders := make([]func(http.Handler) http.Handler, 0, len(r.curMiddlewares)+len(h)+1)
for _, m := range r.curMiddlewares {
if m != nil {
@@ -96,7 +96,7 @@ func (r *Route) wrapMiddlewareAndHandler(h []any) ([]func(http.Handler) http.Han
}
middlewares := handlerProviders[:len(handlerProviders)-1]
handlerFunc := handlerProviders[len(handlerProviders)-1](nil).ServeHTTP
- mockPoint := RouteMockPoint(MockAfterMiddlewares)
+ mockPoint := RouterMockPoint(MockAfterMiddlewares)
if mockPoint != nil {
middlewares = append(middlewares, mockPoint)
}
@@ -105,72 +105,72 @@ func (r *Route) wrapMiddlewareAndHandler(h []any) ([]func(http.Handler) http.Han
// Methods adds the same handlers for multiple http "methods" (separated by ",").
// If any method is invalid, the lower level router will panic.
-func (r *Route) Methods(methods, pattern string, h ...any) {
+func (r *Router) Methods(methods, pattern string, h ...any) {
middlewares, handlerFunc := r.wrapMiddlewareAndHandler(h)
fullPattern := r.getPattern(pattern)
if strings.Contains(methods, ",") {
methods := strings.Split(methods, ",")
for _, method := range methods {
- r.R.With(middlewares...).Method(strings.TrimSpace(method), fullPattern, handlerFunc)
+ r.chiRouter.With(middlewares...).Method(strings.TrimSpace(method), fullPattern, handlerFunc)
}
} else {
- r.R.With(middlewares...).Method(methods, fullPattern, handlerFunc)
+ r.chiRouter.With(middlewares...).Method(methods, fullPattern, handlerFunc)
}
}
-// Mount attaches another Route along ./pattern/*
-func (r *Route) Mount(pattern string, subR *Route) {
- subR.Use(r.curMiddlewares...)
- r.R.Mount(r.getPattern(pattern), subR.R)
+// Mount attaches another Router along ./pattern/*
+func (r *Router) Mount(pattern string, subRouter *Router) {
+ subRouter.Use(r.curMiddlewares...)
+ r.chiRouter.Mount(r.getPattern(pattern), subRouter.chiRouter)
}
// Any delegate requests for all methods
-func (r *Route) Any(pattern string, h ...any) {
+func (r *Router) Any(pattern string, h ...any) {
middlewares, handlerFunc := r.wrapMiddlewareAndHandler(h)
- r.R.With(middlewares...).HandleFunc(r.getPattern(pattern), handlerFunc)
+ r.chiRouter.With(middlewares...).HandleFunc(r.getPattern(pattern), handlerFunc)
}
// Delete delegate delete method
-func (r *Route) Delete(pattern string, h ...any) {
+func (r *Router) Delete(pattern string, h ...any) {
r.Methods("DELETE", pattern, h...)
}
// Get delegate get method
-func (r *Route) Get(pattern string, h ...any) {
+func (r *Router) Get(pattern string, h ...any) {
r.Methods("GET", pattern, h...)
}
// Head delegate head method
-func (r *Route) Head(pattern string, h ...any) {
+func (r *Router) Head(pattern string, h ...any) {
r.Methods("HEAD", pattern, h...)
}
// Post delegate post method
-func (r *Route) Post(pattern string, h ...any) {
+func (r *Router) Post(pattern string, h ...any) {
r.Methods("POST", pattern, h...)
}
// Put delegate put method
-func (r *Route) Put(pattern string, h ...any) {
+func (r *Router) Put(pattern string, h ...any) {
r.Methods("PUT", pattern, h...)
}
// Patch delegate patch method
-func (r *Route) Patch(pattern string, h ...any) {
+func (r *Router) Patch(pattern string, h ...any) {
r.Methods("PATCH", pattern, h...)
}
// ServeHTTP implements http.Handler
-func (r *Route) ServeHTTP(w http.ResponseWriter, req *http.Request) {
- r.normalizeRequestPath(w, req, r.R)
+func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
+ r.normalizeRequestPath(w, req, r.chiRouter)
}
// NotFound defines a handler to respond whenever a route could not be found.
-func (r *Route) NotFound(h http.HandlerFunc) {
- r.R.NotFound(h)
+func (r *Router) NotFound(h http.HandlerFunc) {
+ r.chiRouter.NotFound(h)
}
-func (r *Route) normalizeRequestPath(resp http.ResponseWriter, req *http.Request, next http.Handler) {
+func (r *Router) normalizeRequestPath(resp http.ResponseWriter, req *http.Request, next http.Handler) {
normalized := false
normalizedPath := req.URL.EscapedPath()
if normalizedPath == "" {
@@ -226,13 +226,13 @@ func (r *Route) normalizeRequestPath(resp http.ResponseWriter, req *http.Request
}
// Combo delegates requests to Combo
-func (r *Route) Combo(pattern string, h ...any) *Combo {
+func (r *Router) Combo(pattern string, h ...any) *Combo {
return &Combo{r, pattern, h}
}
// Combo represents a tiny group routes with same pattern
type Combo struct {
- r *Route
+ r *Router
pattern string
h []any
}
diff --git a/modules/web/route_test.go b/modules/web/route_test.go
index c5595a02a3..6e4c309293 100644
--- a/modules/web/route_test.go
+++ b/modules/web/route_test.go
@@ -22,7 +22,7 @@ func TestRoute1(t *testing.T) {
recorder := httptest.NewRecorder()
recorder.Body = buff
- r := NewRoute()
+ r := NewRouter()
r.Get("/{username}/{reponame}/{type:issues|pulls}", func(resp http.ResponseWriter, req *http.Request) {
username := chi.URLParam(req, "username")
assert.EqualValues(t, "gitea", username)
@@ -45,7 +45,7 @@ func TestRoute2(t *testing.T) {
hit := -1
- r := NewRoute()
+ r := NewRouter()
r.Group("/{username}/{reponame}", func() {
r.Group("", func() {
r.Get("/{type:issues|pulls}", func(resp http.ResponseWriter, req *http.Request) {
@@ -121,8 +121,8 @@ func TestRoute3(t *testing.T) {
hit := -1
- m := NewRoute()
- r := NewRoute()
+ m := NewRouter()
+ r := NewRouter()
r.Mount("/api/v1", m)
m.Group("/repos", func() {
@@ -189,7 +189,7 @@ func TestRouteNormalizePath(t *testing.T) {
recorder.Body = bytes.NewBuffer(nil)
actualPaths := paths{EscapedPath: "(none)", RawPath: "(none)", Path: "(none)"}
- r := NewRoute()
+ r := NewRouter()
r.Get("/*", func(resp http.ResponseWriter, req *http.Request) {
actualPaths.EscapedPath = req.URL.EscapedPath()
actualPaths.RawPath = req.URL.RawPath
diff --git a/modules/web/routemock.go b/modules/web/routemock.go
index cb41f63b91..e85b0db738 100644
--- a/modules/web/routemock.go
+++ b/modules/web/routemock.go
@@ -14,14 +14,14 @@ const MockAfterMiddlewares = "MockAfterMiddlewares"
var routeMockPoints = map[string]func(next http.Handler) http.Handler{}
-// RouteMockPoint registers a mock point as a middleware for testing, example:
+// RouterMockPoint registers a mock point as a middleware for testing, example:
//
-// r.Use(web.RouteMockPoint("my-mock-point-1"))
-// r.Get("/foo", middleware2, web.RouteMockPoint("my-mock-point-2"), middleware2, handler)
+// r.Use(web.RouterMockPoint("my-mock-point-1"))
+// r.Get("/foo", middleware2, web.RouterMockPoint("my-mock-point-2"), middleware2, handler)
//
// Then use web.RouteMock to mock the route execution.
// It only takes effect in testing mode (setting.IsInTesting == true).
-func RouteMockPoint(pointName string) func(next http.Handler) http.Handler {
+func RouterMockPoint(pointName string) func(next http.Handler) http.Handler {
if !setting.IsInTesting {
return nil
}
diff --git a/modules/web/routemock_test.go b/modules/web/routemock_test.go
index 04c6d1d82e..89cfaacdd1 100644
--- a/modules/web/routemock_test.go
+++ b/modules/web/routemock_test.go
@@ -16,7 +16,7 @@ import (
func TestRouteMock(t *testing.T) {
setting.IsInTesting = true
- r := NewRoute()
+ r := NewRouter()
middleware1 := func(resp http.ResponseWriter, req *http.Request) {
resp.Header().Set("X-Test-Middleware1", "m1")
}
@@ -26,7 +26,7 @@ func TestRouteMock(t *testing.T) {
handler := func(resp http.ResponseWriter, req *http.Request) {
resp.Header().Set("X-Test-Handler", "h")
}
- r.Get("/foo", middleware1, RouteMockPoint("mock-point"), middleware2, handler)
+ r.Get("/foo", middleware1, RouterMockPoint("mock-point"), middleware2, handler)
// normal request
recorder := httptest.NewRecorder()
diff --git a/routers/api/actions/actions.go b/routers/api/actions/actions.go
index a418b3a1c4..6f03f290ea 100644
--- a/routers/api/actions/actions.go
+++ b/routers/api/actions/actions.go
@@ -11,8 +11,8 @@ import (
"code.gitea.io/gitea/routers/api/actions/runner"
)
-func Routes(prefix string) *web.Route {
- m := web.NewRoute()
+func Routes(prefix string) *web.Router {
+ m := web.NewRouter()
path, handler := ping.NewPingServiceHandler()
m.Post(path+"*", http.StripPrefix(prefix, handler).ServeHTTP)
diff --git a/routers/api/actions/artifacts.go b/routers/api/actions/artifacts.go
index 72a2a26c47..da5850589f 100644
--- a/routers/api/actions/artifacts.go
+++ b/routers/api/actions/artifacts.go
@@ -101,8 +101,8 @@ func init() {
})
}
-func ArtifactsRoutes(prefix string) *web.Route {
- m := web.NewRoute()
+func ArtifactsRoutes(prefix string) *web.Router {
+ m := web.NewRouter()
m.Use(ArtifactContexter())
r := artifactRoutes{
@@ -457,7 +457,7 @@ func (ar artifactRoutes) downloadArtifact(ctx *ArtifactContext) {
return
}
- artifactID := ctx.ParamsInt64("artifact_id")
+ artifactID := ctx.PathParamInt64("artifact_id")
artifact, exist, err := db.GetByID[actions.ActionArtifact](ctx, artifactID)
if err != nil {
log.Error("Error getting artifact: %v", err)
diff --git a/routers/api/actions/artifacts_utils.go b/routers/api/actions/artifacts_utils.go
index 3517d57f78..a4ca5797dc 100644
--- a/routers/api/actions/artifacts_utils.go
+++ b/routers/api/actions/artifacts_utils.go
@@ -34,7 +34,7 @@ func validateArtifactName(ctx *ArtifactContext, artifactName string) bool {
func validateRunID(ctx *ArtifactContext) (*actions.ActionTask, int64, bool) {
task := ctx.ActionTask
- runID := ctx.ParamsInt64("run_id")
+ runID := ctx.PathParamInt64("run_id")
if task.Job.RunID != runID {
log.Error("Error runID not match")
ctx.Error(http.StatusBadRequest, "run-id does not match")
@@ -55,7 +55,7 @@ func validateRunIDV4(ctx *ArtifactContext, rawRunID string) (*actions.ActionTask
}
func validateArtifactHash(ctx *ArtifactContext, artifactName string) bool {
- paramHash := ctx.Params("artifact_hash")
+ paramHash := ctx.PathParam("artifact_hash")
// use artifact name to create upload url
artifactHash := fmt.Sprintf("%x", md5.Sum([]byte(artifactName)))
if paramHash == artifactHash {
diff --git a/routers/api/actions/artifactsv4.go b/routers/api/actions/artifactsv4.go
index 2ace9f915f..e78ed7a0c2 100644
--- a/routers/api/actions/artifactsv4.go
+++ b/routers/api/actions/artifactsv4.go
@@ -129,8 +129,8 @@ func ArtifactV4Contexter() func(next http.Handler) http.Handler {
}
}
-func ArtifactsV4Routes(prefix string) *web.Route {
- m := web.NewRoute()
+func ArtifactsV4Routes(prefix string) *web.Router {
+ m := web.NewRouter()
r := artifactV4Routes{
prefix: prefix,
diff --git a/routers/api/packages/alpine/alpine.go b/routers/api/packages/alpine/alpine.go
index 5127319807..4b652c9ecc 100644
--- a/routers/api/packages/alpine/alpine.go
+++ b/routers/api/packages/alpine/alpine.go
@@ -73,7 +73,7 @@ func GetRepositoryFile(ctx *context.Context) {
pv,
&packages_service.PackageFileInfo{
Filename: alpine_service.IndexArchiveFilename,
- CompositeKey: fmt.Sprintf("%s|%s|%s", ctx.Params("branch"), ctx.Params("repository"), ctx.Params("architecture")),
+ CompositeKey: fmt.Sprintf("%s|%s|%s", ctx.PathParam("branch"), ctx.PathParam("repository"), ctx.PathParam("architecture")),
},
)
if err != nil {
@@ -89,8 +89,8 @@ func GetRepositoryFile(ctx *context.Context) {
}
func UploadPackageFile(ctx *context.Context) {
- branch := strings.TrimSpace(ctx.Params("branch"))
- repository := strings.TrimSpace(ctx.Params("repository"))
+ branch := strings.TrimSpace(ctx.PathParam("branch"))
+ repository := strings.TrimSpace(ctx.PathParam("repository"))
if branch == "" || repository == "" {
apiError(ctx, http.StatusBadRequest, "invalid branch or repository")
return
@@ -182,14 +182,14 @@ func UploadPackageFile(ctx *context.Context) {
}
func DownloadPackageFile(ctx *context.Context) {
- branch := ctx.Params("branch")
- repository := ctx.Params("repository")
- architecture := ctx.Params("architecture")
+ branch := ctx.PathParam("branch")
+ repository := ctx.PathParam("repository")
+ architecture := ctx.PathParam("architecture")
opts := &packages_model.PackageFileSearchOptions{
OwnerID: ctx.Package.Owner.ID,
PackageType: packages_model.TypeAlpine,
- Query: ctx.Params("filename"),
+ Query: ctx.PathParam("filename"),
CompositeKey: fmt.Sprintf("%s|%s|%s", branch, repository, architecture),
}
pfs, _, err := packages_model.SearchFiles(ctx, opts)
@@ -230,12 +230,12 @@ func DownloadPackageFile(ctx *context.Context) {
}
func DeletePackageFile(ctx *context.Context) {
- branch, repository, architecture := ctx.Params("branch"), ctx.Params("repository"), ctx.Params("architecture")
+ branch, repository, architecture := ctx.PathParam("branch"), ctx.PathParam("repository"), ctx.PathParam("architecture")
pfs, _, err := packages_model.SearchFiles(ctx, &packages_model.PackageFileSearchOptions{
OwnerID: ctx.Package.Owner.ID,
PackageType: packages_model.TypeAlpine,
- Query: ctx.Params("filename"),
+ Query: ctx.PathParam("filename"),
CompositeKey: fmt.Sprintf("%s|%s|%s", branch, repository, architecture),
})
if err != nil {
diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go
index 4122f632ff..0f42e8f59e 100644
--- a/routers/api/packages/api.go
+++ b/routers/api/packages/api.go
@@ -74,7 +74,7 @@ func reqPackageAccess(accessMode perm.AccessMode) func(ctx *context.Context) {
}
}
-func verifyAuth(r *web.Route, authMethods []auth.Method) {
+func verifyAuth(r *web.Router, authMethods []auth.Method) {
if setting.Service.EnableReverseProxyAuth {
authMethods = append(authMethods, &auth.ReverseProxy{})
}
@@ -94,8 +94,8 @@ func verifyAuth(r *web.Route, authMethods []auth.Method) {
// CommonRoutes provide endpoints for most package managers (except containers - see below)
// These are mounted on `/api/packages` (not `/api/v1/packages`)
-func CommonRoutes() *web.Route {
- r := web.NewRoute()
+func CommonRoutes() *web.Router {
+ r := web.NewRouter()
r.Use(context.PackageContexter())
@@ -264,15 +264,15 @@ func CommonRoutes() *web.Route {
)
r.Get("/*", func(ctx *context.Context) {
- m := downloadPattern.FindStringSubmatch(ctx.Params("*"))
+ m := downloadPattern.FindStringSubmatch(ctx.PathParam("*"))
if len(m) == 0 {
ctx.Status(http.StatusNotFound)
return
}
- ctx.SetParams("channel", strings.TrimSuffix(m[1], "/"))
- ctx.SetParams("architecture", m[2])
- ctx.SetParams("filename", m[3])
+ ctx.SetPathParam("channel", strings.TrimSuffix(m[1], "/"))
+ ctx.SetPathParam("architecture", m[2])
+ ctx.SetPathParam("filename", m[3])
switch m[3] {
case "repodata.json", "repodata.json.bz2", "current_repodata.json", "current_repodata.json.bz2":
@@ -282,14 +282,14 @@ func CommonRoutes() *web.Route {
}
})
r.Put("/*", reqPackageAccess(perm.AccessModeWrite), func(ctx *context.Context) {
- m := uploadPattern.FindStringSubmatch(ctx.Params("*"))
+ m := uploadPattern.FindStringSubmatch(ctx.PathParam("*"))
if len(m) == 0 {
ctx.Status(http.StatusNotFound)
return
}
- ctx.SetParams("channel", strings.TrimSuffix(m[1], "/"))
- ctx.SetParams("filename", m[2])
+ ctx.SetPathParam("channel", strings.TrimSuffix(m[1], "/"))
+ ctx.SetPathParam("filename", m[2])
conda.UploadPackageFile(ctx)
})
@@ -339,11 +339,11 @@ func CommonRoutes() *web.Route {
// Manual mapping of routes because the package name contains slashes which chi does not support
// https://go.dev/ref/mod#goproxy-protocol
r.Get("/*", func(ctx *context.Context) {
- path := ctx.Params("*")
+ path := ctx.PathParam("*")
if strings.HasSuffix(path, "/@latest") {
- ctx.SetParams("name", path[:len(path)-len("/@latest")])
- ctx.SetParams("version", "latest")
+ ctx.SetPathParam("name", path[:len(path)-len("/@latest")])
+ ctx.SetPathParam("version", "latest")
goproxy.PackageVersionMetadata(ctx)
return
@@ -355,7 +355,7 @@ func CommonRoutes() *web.Route {
return
}
- ctx.SetParams("name", parts[0])
+ ctx.SetPathParam("name", parts[0])
// <package/name>/@v/list
if parts[1] == "list" {
@@ -365,21 +365,21 @@ func CommonRoutes() *web.Route {
// <package/name>/@v/<version>.zip
if strings.HasSuffix(parts[1], ".zip") {
- ctx.SetParams("version", parts[1][:len(parts[1])-len(".zip")])
+ ctx.SetPathParam("version", parts[1][:len(parts[1])-len(".zip")])
goproxy.DownloadPackageFile(ctx)
return
}
// <package/name>/@v/<version>.info
if strings.HasSuffix(parts[1], ".info") {
- ctx.SetParams("version", parts[1][:len(parts[1])-len(".info")])
+ ctx.SetPathParam("version", parts[1][:len(parts[1])-len(".info")])
goproxy.PackageVersionMetadata(ctx)
return
}
// <package/name>/@v/<version>.mod
if strings.HasSuffix(parts[1], ".mod") {
- ctx.SetParams("version", parts[1][:len(parts[1])-len(".mod")])
+ ctx.SetPathParam("version", parts[1][:len(parts[1])-len(".mod")])
goproxy.PackageVersionGoModContent(ctx)
return
@@ -525,7 +525,7 @@ func CommonRoutes() *web.Route {
)
r.Methods("HEAD,GET,PUT,DELETE", "*", func(ctx *context.Context) {
- path := ctx.Params("*")
+ path := ctx.PathParam("*")
isHead := ctx.Req.Method == "HEAD"
isGetHead := ctx.Req.Method == "HEAD" || ctx.Req.Method == "GET"
isPut := ctx.Req.Method == "PUT"
@@ -533,15 +533,15 @@ func CommonRoutes() *web.Route {
m := repoPattern.FindStringSubmatch(path)
if len(m) == 2 && isGetHead {
- ctx.SetParams("group", strings.Trim(m[1], "/"))
+ ctx.SetPathParam("group", strings.Trim(m[1], "/"))
rpm.GetRepositoryConfig(ctx)
return
}
m = repoFilePattern.FindStringSubmatch(path)
if len(m) == 3 && isGetHead {
- ctx.SetParams("group", strings.Trim(m[1], "/"))
- ctx.SetParams("filename", m[2])
+ ctx.SetPathParam("group", strings.Trim(m[1], "/"))
+ ctx.SetPathParam("filename", m[2])
if isHead {
rpm.CheckRepositoryFileExistence(ctx)
} else {
@@ -556,17 +556,17 @@ func CommonRoutes() *web.Route {
if ctx.Written() {
return
}
- ctx.SetParams("group", strings.Trim(m[1], "/"))
+ ctx.SetPathParam("group", strings.Trim(m[1], "/"))
rpm.UploadPackageFile(ctx)
return
}
m = filePattern.FindStringSubmatch(path)
if len(m) == 6 && (isGetHead || isDelete) {
- ctx.SetParams("group", strings.Trim(m[1], "/"))
- ctx.SetParams("name", m[2])
- ctx.SetParams("version", m[3])
- ctx.SetParams("architecture", m[4])
+ ctx.SetPathParam("group", strings.Trim(m[1], "/"))
+ ctx.SetPathParam("name", m[2])
+ ctx.SetPathParam("version", m[3])
+ ctx.SetPathParam("architecture", m[4])
if isGetHead {
rpm.DownloadPackageFile(ctx)
} else {
@@ -607,13 +607,13 @@ func CommonRoutes() *web.Route {
r.Get("", func(ctx *context.Context) {
// Can't use normal routes here: https://github.com/go-chi/chi/issues/781
- version := ctx.Params("version")
+ version := ctx.PathParam("version")
if strings.HasSuffix(version, ".zip") {
swift.CheckAcceptMediaType(swift.AcceptZip)(ctx)
if ctx.Written() {
return
}
- ctx.SetParams("version", version[:len(version)-4])
+ ctx.SetPathParam("version", version[:len(version)-4])
swift.DownloadPackageFile(ctx)
} else {
swift.CheckAcceptMediaType(swift.AcceptJSON)(ctx)
@@ -621,7 +621,7 @@ func CommonRoutes() *web.Route {
return
}
if strings.HasSuffix(version, ".json") {
- ctx.SetParams("version", version[:len(version)-5])
+ ctx.SetPathParam("version", version[:len(version)-5])
}
swift.PackageVersionMetadata(ctx)
}
@@ -651,8 +651,8 @@ func CommonRoutes() *web.Route {
// ContainerRoutes provides endpoints that implement the OCI API to serve containers
// These have to be mounted on `/v2/...` to comply with the OCI spec:
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md
-func ContainerRoutes() *web.Route {
- r := web.NewRoute()
+func ContainerRoutes() *web.Router {
+ r := web.NewRouter()
r.Use(context.PackageContexter())
@@ -700,7 +700,7 @@ func ContainerRoutes() *web.Route {
// Manual mapping of routes because {image} can contain slashes which chi does not support
r.Methods("HEAD,GET,POST,PUT,PATCH,DELETE", "/*", func(ctx *context.Context) {
- path := ctx.Params("*")
+ path := ctx.PathParam("*")
isHead := ctx.Req.Method == "HEAD"
isGet := ctx.Req.Method == "GET"
isPost := ctx.Req.Method == "POST"
@@ -714,7 +714,7 @@ func ContainerRoutes() *web.Route {
return
}
- ctx.SetParams("image", path[:len(path)-14])
+ ctx.SetPathParam("image", path[:len(path)-14])
container.VerifyImageName(ctx)
if ctx.Written() {
return
@@ -724,7 +724,7 @@ func ContainerRoutes() *web.Route {
return
}
if isGet && strings.HasSuffix(path, "/tags/list") {
- ctx.SetParams("image", path[:len(path)-10])
+ ctx.SetPathParam("image", path[:len(path)-10])
container.VerifyImageName(ctx)
if ctx.Written() {
return
@@ -741,13 +741,13 @@ func ContainerRoutes() *web.Route {
return
}
- ctx.SetParams("image", m[1])
+ ctx.SetPathParam("image", m[1])
container.VerifyImageName(ctx)
if ctx.Written() {
return
}
- ctx.SetParams("uuid", m[2])
+ ctx.SetPathParam("uuid", m[2])
if isGet {
container.GetUploadBlob(ctx)
@@ -762,13 +762,13 @@ func ContainerRoutes() *web.Route {
}
m = blobsPattern.FindStringSubmatch(path)
if len(m) == 3 && (isHead || isGet || isDelete) {
- ctx.SetParams("image", m[1])
+ ctx.SetPathParam("image", m[1])
container.VerifyImageName(ctx)
if ctx.Written() {
return
}
- ctx.SetParams("digest", m[2])
+ ctx.SetPathParam("digest", m[2])
if isHead {
container.HeadBlob(ctx)
@@ -785,13 +785,13 @@ func ContainerRoutes() *web.Route {
}
m = manifestsPattern.FindStringSubmatch(path)
if len(m) == 3 && (isHead || isGet || isPut || isDelete) {
- ctx.SetParams("image", m[1])
+ ctx.SetPathParam("image", m[1])
container.VerifyImageName(ctx)
if ctx.Written() {
return
}
- ctx.SetParams("reference", m[2])
+ ctx.SetPathParam("reference", m[2])
if isHead {
container.HeadManifest(ctx)
diff --git a/routers/api/packages/cargo/cargo.go b/routers/api/packages/cargo/cargo.go
index 140e532efd..3d8407e6b6 100644
--- a/routers/api/packages/cargo/cargo.go
+++ b/routers/api/packages/cargo/cargo.go
@@ -55,7 +55,7 @@ func RepositoryConfig(ctx *context.Context) {
}
func EnumeratePackageVersions(ctx *context.Context) {
- p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.Params("package"))
+ p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.PathParam("package"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
@@ -173,11 +173,11 @@ func DownloadPackageFile(ctx *context.Context) {
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
PackageType: packages_model.TypeCargo,
- Name: ctx.Params("package"),
- Version: ctx.Params("version"),
+ Name: ctx.PathParam("package"),
+ Version: ctx.PathParam("version"),
},
&packages_service.PackageFileInfo{
- Filename: strings.ToLower(fmt.Sprintf("%s-%s.crate", ctx.Params("package"), ctx.Params("version"))),
+ Filename: strings.ToLower(fmt.Sprintf("%s-%s.crate", ctx.PathParam("package"), ctx.PathParam("version"))),
},
)
if err != nil {
@@ -274,7 +274,7 @@ func UnyankPackage(ctx *context.Context) {
}
func yankPackage(ctx *context.Context, yank bool) {
- pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.Params("package"), ctx.Params("version"))
+ pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.PathParam("package"), ctx.PathParam("version"))
if err != nil {
if err == packages_model.ErrPackageNotExist {
apiError(ctx, http.StatusNotFound, err)
diff --git a/routers/api/packages/chef/chef.go b/routers/api/packages/chef/chef.go
index b49f4e9d0a..b3cdf12697 100644
--- a/routers/api/packages/chef/chef.go
+++ b/routers/api/packages/chef/chef.go
@@ -150,7 +150,7 @@ func EnumeratePackages(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_show.rb
func PackageMetadata(ctx *context.Context) {
- packageName := ctx.Params("name")
+ packageName := ctx.PathParam("name")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, packageName)
if err != nil {
@@ -211,8 +211,8 @@ func PackageMetadata(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_show.rb
func PackageVersionMetadata(ctx *context.Context) {
- packageName := ctx.Params("name")
- packageVersion := strings.ReplaceAll(ctx.Params("version"), "_", ".") // Chef calls this endpoint with "_" instead of "."?!
+ packageName := ctx.PathParam("name")
+ packageVersion := strings.ReplaceAll(ctx.PathParam("version"), "_", ".") // Chef calls this endpoint with "_" instead of "."?!
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, packageName, packageVersion)
if err != nil {
@@ -325,7 +325,7 @@ func UploadPackage(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_download.rb
func DownloadPackage(ctx *context.Context) {
- pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.Params("name"), ctx.Params("version"))
+ pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.PathParam("name"), ctx.PathParam("version"))
if err != nil {
if err == packages_model.ErrPackageNotExist {
apiError(ctx, http.StatusNotFound, err)
@@ -354,8 +354,8 @@ func DownloadPackage(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_unshare.rb
func DeletePackageVersion(ctx *context.Context) {
- packageName := ctx.Params("name")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("name")
+ packageVersion := ctx.PathParam("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
ctx,
@@ -381,7 +381,7 @@ func DeletePackageVersion(ctx *context.Context) {
// https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_unshare.rb
func DeletePackage(ctx *context.Context) {
- pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.Params("name"))
+ pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.PathParam("name"))
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
diff --git a/routers/api/packages/composer/composer.go b/routers/api/packages/composer/composer.go
index a045da40de..40f72f6484 100644
--- a/routers/api/packages/composer/composer.go
+++ b/routers/api/packages/composer/composer.go
@@ -134,8 +134,8 @@ func EnumeratePackages(ctx *context.Context) {
// PackageMetadata returns the metadata for a single package
// https://packagist.org/apidoc#get-package-data
func PackageMetadata(ctx *context.Context) {
- vendorName := ctx.Params("vendorname")
- projectName := ctx.Params("projectname")
+ vendorName := ctx.PathParam("vendorname")
+ projectName := ctx.PathParam("projectname")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeComposer, vendorName+"/"+projectName)
if err != nil {
@@ -168,11 +168,11 @@ func DownloadPackageFile(ctx *context.Context) {
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
PackageType: packages_model.TypeComposer,
- Name: ctx.Params("package"),
- Version: ctx.Params("version"),
+ Name: ctx.PathParam("package"),
+ Version: ctx.PathParam("version"),
},
&packages_service.PackageFileInfo{
- Filename: ctx.Params("filename"),
+ Filename: ctx.PathParam("filename"),
},
)
if err != nil {
diff --git a/routers/api/packages/conan/conan.go b/routers/api/packages/conan/conan.go
index 07ea3eda34..7afca2fab1 100644
--- a/routers/api/packages/conan/conan.go
+++ b/routers/api/packages/conan/conan.go
@@ -72,11 +72,11 @@ func baseURL(ctx *context.Context) string {
// ExtractPathParameters is a middleware to extract common parameters from path
func ExtractPathParameters(ctx *context.Context) {
rref, err := conan_module.NewRecipeReference(
- ctx.Params("name"),
- ctx.Params("version"),
- ctx.Params("user"),
- ctx.Params("channel"),
- ctx.Params("recipe_revision"),
+ ctx.PathParam("name"),
+ ctx.PathParam("version"),
+ ctx.PathParam("user"),
+ ctx.PathParam("channel"),
+ ctx.PathParam("recipe_revision"),
)
if err != nil {
apiError(ctx, http.StatusBadRequest, err)
@@ -85,14 +85,14 @@ func ExtractPathParameters(ctx *context.Context) {
ctx.Data[recipeReferenceKey] = rref
- reference := ctx.Params("package_reference")
+ reference := ctx.PathParam("package_reference")
var pref *conan_module.PackageReference
if reference != "" {
pref, err = conan_module.NewPackageReference(
rref,
reference,
- ctx.Params("package_revision"),
+ ctx.PathParam("package_revision"),
)
if err != nil {
apiError(ctx, http.StatusBadRequest, err)
@@ -304,7 +304,7 @@ func uploadFile(ctx *context.Context, fileFilter container.Set[string], fileKey
rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference)
pref := ctx.Data[packageReferenceKey].(*conan_module.PackageReference)
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
if !fileFilter.Contains(filename) {
apiError(ctx, http.StatusBadRequest, nil)
return
@@ -444,7 +444,7 @@ func DownloadPackageFile(ctx *context.Context) {
func downloadFile(ctx *context.Context, fileFilter container.Set[string], fileKey string) {
rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference)
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
if !fileFilter.Contains(filename) {
apiError(ctx, http.StatusBadRequest, nil)
return
diff --git a/routers/api/packages/conda/conda.go b/routers/api/packages/conda/conda.go
index c7e4544d52..7a46681235 100644
--- a/routers/api/packages/conda/conda.go
+++ b/routers/api/packages/conda/conda.go
@@ -66,7 +66,7 @@ func EnumeratePackages(ctx *context.Context) {
repoData := &RepoData{
Info: Info{
- Subdir: ctx.Params("architecture"),
+ Subdir: ctx.PathParam("architecture"),
},
Packages: make(map[string]*PackageInfo),
PackagesConda: make(map[string]*PackageInfo),
@@ -75,7 +75,7 @@ func EnumeratePackages(ctx *context.Context) {
pfs, err := conda_model.SearchFiles(ctx, &conda_model.FileSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Channel: ctx.Params("channel"),
+ Channel: ctx.PathParam("channel"),
Subdir: repoData.Info.Subdir,
})
if err != nil {
@@ -151,7 +151,7 @@ func EnumeratePackages(ctx *context.Context) {
var w io.Writer = resp
- if strings.HasSuffix(ctx.Params("filename"), ".json") {
+ if strings.HasSuffix(ctx.PathParam("filename"), ".json") {
resp.Header().Set("Content-Type", "application/json")
} else {
resp.Header().Set("Content-Type", "application/x-bzip2")
@@ -191,7 +191,7 @@ func UploadPackageFile(ctx *context.Context) {
defer buf.Close()
var pck *conda_module.Package
- if strings.HasSuffix(strings.ToLower(ctx.Params("filename")), ".tar.bz2") {
+ if strings.HasSuffix(strings.ToLower(ctx.PathParam("filename")), ".tar.bz2") {
pck, err = conda_module.ParsePackageBZ2(buf)
} else {
pck, err = conda_module.ParsePackageConda(buf, buf.Size())
@@ -212,7 +212,7 @@ func UploadPackageFile(ctx *context.Context) {
fullName := pck.Name
- channel := ctx.Params("channel")
+ channel := ctx.PathParam("channel")
if channel != "" {
fullName = channel + "/" + pck.Name
}
@@ -277,9 +277,9 @@ func UploadPackageFile(ctx *context.Context) {
func DownloadPackageFile(ctx *context.Context) {
pfs, err := conda_model.SearchFiles(ctx, &conda_model.FileSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Channel: ctx.Params("channel"),
- Subdir: ctx.Params("architecture"),
- Filename: ctx.Params("filename"),
+ Channel: ctx.PathParam("channel"),
+ Subdir: ctx.PathParam("architecture"),
+ Filename: ctx.PathParam("filename"),
})
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
diff --git a/routers/api/packages/container/container.go b/routers/api/packages/container/container.go
index 5007037bee..74a3295f09 100644
--- a/routers/api/packages/container/container.go
+++ b/routers/api/packages/container/container.go
@@ -131,7 +131,7 @@ func ReqContainerAccess(ctx *context.Context) {
// VerifyImageName is a middleware which checks if the image name is allowed
func VerifyImageName(ctx *context.Context) {
- if !imageNamePattern.MatchString(ctx.Params("image")) {
+ if !imageNamePattern.MatchString(ctx.PathParam("image")) {
apiErrorDefined(ctx, errNameInvalid)
}
}
@@ -216,7 +216,7 @@ func GetRepositoryList(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#single-post
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
func InitiateUploadBlob(ctx *context.Context) {
- image := ctx.Params("image")
+ image := ctx.PathParam("image")
mount := ctx.FormTrim("mount")
from := ctx.FormTrim("from")
@@ -305,7 +305,7 @@ func InitiateUploadBlob(ctx *context.Context) {
// https://docs.docker.com/registry/spec/api/#get-blob-upload
func GetUploadBlob(ctx *context.Context) {
- uuid := ctx.Params("uuid")
+ uuid := ctx.PathParam("uuid")
upload, err := packages_model.GetBlobUploadByID(ctx, uuid)
if err != nil {
@@ -326,9 +326,9 @@ func GetUploadBlob(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
func UploadBlob(ctx *context.Context) {
- image := ctx.Params("image")
+ image := ctx.PathParam("image")
- uploader, err := container_service.NewBlobUploader(ctx, ctx.Params("uuid"))
+ uploader, err := container_service.NewBlobUploader(ctx, ctx.PathParam("uuid"))
if err != nil {
if err == packages_model.ErrPackageBlobUploadNotExist {
apiErrorDefined(ctx, errBlobUploadUnknown)
@@ -371,7 +371,7 @@ func UploadBlob(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks
func EndUploadBlob(ctx *context.Context) {
- image := ctx.Params("image")
+ image := ctx.PathParam("image")
digest := ctx.FormTrim("digest")
if digest == "" {
@@ -379,7 +379,7 @@ func EndUploadBlob(ctx *context.Context) {
return
}
- uploader, err := container_service.NewBlobUploader(ctx, ctx.Params("uuid"))
+ uploader, err := container_service.NewBlobUploader(ctx, ctx.PathParam("uuid"))
if err != nil {
if err == packages_model.ErrPackageBlobUploadNotExist {
apiErrorDefined(ctx, errBlobUploadUnknown)
@@ -446,7 +446,7 @@ func EndUploadBlob(ctx *context.Context) {
// https://docs.docker.com/registry/spec/api/#delete-blob-upload
func CancelUploadBlob(ctx *context.Context) {
- uuid := ctx.Params("uuid")
+ uuid := ctx.PathParam("uuid")
_, err := packages_model.GetBlobUploadByID(ctx, uuid)
if err != nil {
@@ -469,7 +469,7 @@ func CancelUploadBlob(ctx *context.Context) {
}
func getBlobFromContext(ctx *context.Context) (*packages_model.PackageFileDescriptor, error) {
- d := ctx.Params("digest")
+ d := ctx.PathParam("digest")
if digest.Digest(d).Validate() != nil {
return nil, container_model.ErrContainerBlobNotExist
@@ -477,7 +477,7 @@ func getBlobFromContext(ctx *context.Context) (*packages_model.PackageFileDescri
return workaroundGetContainerBlob(ctx, &container_model.BlobSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Image: ctx.Params("image"),
+ Image: ctx.PathParam("image"),
Digest: d,
})
}
@@ -518,14 +518,14 @@ func GetBlob(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#deleting-blobs
func DeleteBlob(ctx *context.Context) {
- d := ctx.Params("digest")
+ d := ctx.PathParam("digest")
if digest.Digest(d).Validate() != nil {
apiErrorDefined(ctx, errBlobUnknown)
return
}
- if err := deleteBlob(ctx, ctx.Package.Owner.ID, ctx.Params("image"), d); err != nil {
+ if err := deleteBlob(ctx, ctx.Package.Owner.ID, ctx.PathParam("image"), d); err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
}
@@ -537,13 +537,13 @@ func DeleteBlob(ctx *context.Context) {
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-manifests
func UploadManifest(ctx *context.Context) {
- reference := ctx.Params("reference")
+ reference := ctx.PathParam("reference")
mci := &manifestCreationInfo{
MediaType: ctx.Req.Header.Get("Content-Type"),
Owner: ctx.Package.Owner,
Creator: ctx.Doer,
- Image: ctx.Params("image"),
+ Image: ctx.PathParam("image"),
Reference: reference,
IsTagged: digest.Digest(reference).Validate() != nil,
}
@@ -592,11 +592,11 @@ func UploadManifest(ctx *context.Context) {
}
func getBlobSearchOptionsFromContext(ctx *context.Context) (*container_model.BlobSearchOptions, error) {
- reference := ctx.Params("reference")
+ reference := ctx.PathParam("reference")
opts := &container_model.BlobSearchOptions{
OwnerID: ctx.Package.Owner.ID,
- Image: ctx.Params("image"),
+ Image: ctx.PathParam("image"),
IsManifest: true,
}
@@ -719,7 +719,7 @@ func serveBlob(ctx *context.Context, pfd *packages_model.PackageFileDescriptor)
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#content-discovery
func GetTagList(ctx *context.Context) {
- image := ctx.Params("image")
+ image := ctx.PathParam("image")
if _, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.TypeContainer, image); err != nil {
if err == packages_model.ErrPackageNotExist {
diff --git a/routers/api/packages/cran/cran.go b/routers/api/packages/cran/cran.go
index f1d616724a..8a20072cb6 100644
--- a/routers/api/packages/cran/cran.go
+++ b/routers/api/packages/cran/cran.go
@@ -28,18 +28,18 @@ func apiError(ctx *context.Context, status int, obj any) {
}
func EnumerateSourcePackages(ctx *context.Context) {
- enumeratePackages(ctx, ctx.Params("format"), &cran_model.SearchOptions{
+ enumeratePackages(ctx, ctx.PathParam("format"), &cran_model.SearchOptions{
OwnerID: ctx.Package.Owner.ID,
FileType: cran_module.TypeSource,
})
}
func EnumerateBinaryPackages(ctx *context.Context) {
- enumeratePackages(ctx, ctx.Params("format"), &cran_model.SearchOptions{
+ enumeratePackages(ctx, ctx.PathParam("format"), &cran_model.SearchOptions{
OwnerID: ctx.Package.Owner.ID,
FileType: cran_module.TypeBinary,
- Platform: ctx.Params("platform"),
- RVersion: ctx.Params("rversion"),
+ Platform: ctx.PathParam("platform"),
+ RVersion: ctx.PathParam("rversion"),
})
}
@@ -225,7 +225,7 @@ func DownloadSourcePackageFile(ctx *context.Context) {
downloadPackageFile(ctx, &cran_model.SearchOptions{
OwnerID: ctx.Package.Owner.ID,
FileType: cran_module.TypeSource,
- Filename: ctx.Params("filename"),
+ Filename: ctx.PathParam("filename"),
})
}
@@ -233,9 +233,9 @@ func DownloadBinaryPackageFile(ctx *context.Context) {
downloadPackageFile(ctx, &cran_model.SearchOptions{
OwnerID: ctx.Package.Owner.ID,
FileType: cran_module.TypeBinary,
- Platform: ctx.Params("platform"),
- RVersion: ctx.Params("rversion"),
- Filename: ctx.Params("filename"),
+ Platform: ctx.PathParam("platform"),
+ RVersion: ctx.PathParam("rversion"),
+ Filename: ctx.PathParam("filename"),
})
}
diff --git a/routers/api/packages/debian/debian.go b/routers/api/packages/debian/debian.go
index 8c05476cbc..162122ccbd 100644
--- a/routers/api/packages/debian/debian.go
+++ b/routers/api/packages/debian/debian.go
@@ -51,10 +51,10 @@ func GetRepositoryFile(ctx *context.Context) {
return
}
- key := ctx.Params("distribution")
+ key := ctx.PathParam("distribution")
- component := ctx.Params("component")
- architecture := strings.TrimPrefix(ctx.Params("architecture"), "binary-")
+ component := ctx.PathParam("component")
+ architecture := strings.TrimPrefix(ctx.PathParam("architecture"), "binary-")
if component != "" && architecture != "" {
key += "|" + component + "|" + architecture
}
@@ -63,7 +63,7 @@ func GetRepositoryFile(ctx *context.Context) {
ctx,
pv,
&packages_service.PackageFileInfo{
- Filename: ctx.Params("filename"),
+ Filename: ctx.PathParam("filename"),
CompositeKey: key,
},
)
@@ -87,14 +87,14 @@ func GetRepositoryFileByHash(ctx *context.Context) {
return
}
- algorithm := strings.ToLower(ctx.Params("algorithm"))
+ algorithm := strings.ToLower(ctx.PathParam("algorithm"))
if algorithm == "md5sum" {
algorithm = "md5"
}
pfs, _, err := packages_model.SearchFiles(ctx, &packages_model.PackageFileSearchOptions{
VersionID: pv.ID,
- Hash: strings.ToLower(ctx.Params("hash")),
+ Hash: strings.ToLower(ctx.PathParam("hash")),
HashAlgorithm: algorithm,
})
if err != nil {
@@ -120,8 +120,8 @@ func GetRepositoryFileByHash(ctx *context.Context) {
}
func UploadPackageFile(ctx *context.Context) {
- distribution := strings.TrimSpace(ctx.Params("distribution"))
- component := strings.TrimSpace(ctx.Params("component"))
+ distribution := strings.TrimSpace(ctx.PathParam("distribution"))
+ component := strings.TrimSpace(ctx.PathParam("component"))
if distribution == "" || component == "" {
apiError(ctx, http.StatusBadRequest, "invalid distribution or component")
return
@@ -207,8 +207,8 @@ func UploadPackageFile(ctx *context.Context) {
}
func DownloadPackageFile(ctx *context.Context) {
- name := ctx.Params("name")
- version := ctx.Params("version")
+ name := ctx.PathParam("name")
+ version := ctx.PathParam("version")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
@@ -219,8 +219,8 @@ func DownloadPackageFile(ctx *context.Context) {
Version: version,
},
&packages_service.PackageFileInfo{
- Filename: fmt.Sprintf("%s_%s_%s.deb", name, version, ctx.Params("architecture")),
- CompositeKey: fmt.Sprintf("%s|%s", ctx.Params("distribution"), ctx.Params("component")),
+ Filename: fmt.Sprintf("%s_%s_%s.deb", name, version, ctx.PathParam("architecture")),
+ CompositeKey: fmt.Sprintf("%s|%s", ctx.PathParam("distribution"), ctx.PathParam("component")),
},
)
if err != nil {
@@ -240,11 +240,11 @@ func DownloadPackageFile(ctx *context.Context) {
}
func DeletePackageFile(ctx *context.Context) {
- distribution := ctx.Params("distribution")
- component := ctx.Params("component")
- name := ctx.Params("name")
- version := ctx.Params("version")
- architecture := ctx.Params("architecture")
+ distribution := ctx.PathParam("distribution")
+ component := ctx.PathParam("component")
+ name := ctx.PathParam("name")
+ version := ctx.PathParam("version")
+ architecture := ctx.PathParam("architecture")
owner := ctx.Package.Owner
diff --git a/routers/api/packages/generic/generic.go b/routers/api/packages/generic/generic.go
index e66f3ee676..868caf9cf0 100644
--- a/routers/api/packages/generic/generic.go
+++ b/routers/api/packages/generic/generic.go
@@ -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
}
diff --git a/routers/api/packages/goproxy/goproxy.go b/routers/api/packages/goproxy/goproxy.go
index 56a07dbd43..bde29df739 100644
--- a/routers/api/packages/goproxy/goproxy.go
+++ b/routers/api/packages/goproxy/goproxy.go
@@ -28,7 +28,7 @@ func apiError(ctx *context.Context, status int, obj any) {
}
func EnumeratePackageVersions(ctx *context.Context) {
- pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeGo, ctx.Params("name"))
+ pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeGo, ctx.PathParam("name"))
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -50,7 +50,7 @@ func EnumeratePackageVersions(ctx *context.Context) {
}
func PackageVersionMetadata(ctx *context.Context) {
- pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.Params("name"), ctx.Params("version"))
+ pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.PathParam("name"), ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
@@ -70,7 +70,7 @@ func PackageVersionMetadata(ctx *context.Context) {
}
func PackageVersionGoModContent(ctx *context.Context) {
- pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.Params("name"), ctx.Params("version"))
+ pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.PathParam("name"), ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
@@ -90,7 +90,7 @@ func PackageVersionGoModContent(ctx *context.Context) {
}
func DownloadPackageFile(ctx *context.Context) {
- pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.Params("name"), ctx.Params("version"))
+ pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.PathParam("name"), ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
diff --git a/routers/api/packages/helm/helm.go b/routers/api/packages/helm/helm.go
index efdb83ec0e..cb30a20074 100644
--- a/routers/api/packages/helm/helm.go
+++ b/routers/api/packages/helm/helm.go
@@ -101,14 +101,14 @@ func Index(ctx *context.Context) {
// DownloadPackageFile serves the content of a package
func DownloadPackageFile(ctx *context.Context) {
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
OwnerID: ctx.Package.Owner.ID,
Type: packages_model.TypeHelm,
Name: packages_model.SearchValue{
ExactMatch: true,
- Value: ctx.Params("package"),
+ Value: ctx.PathParam("package"),
},
HasFileWithName: filename,
IsInternal: optional.Some(false),
diff --git a/routers/api/packages/maven/maven.go b/routers/api/packages/maven/maven.go
index cb15eae682..1486e83c57 100644
--- a/routers/api/packages/maven/maven.go
+++ b/routers/api/packages/maven/maven.go
@@ -385,7 +385,7 @@ type parameters struct {
}
func extractPathParameters(ctx *context.Context) (parameters, error) {
- parts := strings.Split(ctx.Params("*"), "/")
+ parts := strings.Split(ctx.PathParam("*"), "/")
p := parameters{
Filename: parts[len(parts)-1],
diff --git a/routers/api/packages/npm/npm.go b/routers/api/packages/npm/npm.go
index 84acfffae2..284723e0d7 100644
--- a/routers/api/packages/npm/npm.go
+++ b/routers/api/packages/npm/npm.go
@@ -43,8 +43,8 @@ func apiError(ctx *context.Context, status int, obj any) {
// packageNameFromParams gets the package name from the url parameters
// Variations: /name/, /@scope/name/, /@scope%2Fname/
func packageNameFromParams(ctx *context.Context) string {
- scope := ctx.Params("scope")
- id := ctx.Params("id")
+ scope := ctx.PathParam("scope")
+ id := ctx.PathParam("id")
if scope != "" {
return fmt.Sprintf("@%s/%s", scope, id)
}
@@ -82,8 +82,8 @@ func PackageMetadata(ctx *context.Context) {
// DownloadPackageFile serves the content of a package
func DownloadPackageFile(ctx *context.Context) {
packageName := packageNameFromParams(ctx)
- packageVersion := ctx.Params("version")
- filename := ctx.Params("filename")
+ packageVersion := ctx.PathParam("version")
+ filename := ctx.PathParam("filename")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
@@ -111,7 +111,7 @@ func DownloadPackageFile(ctx *context.Context) {
// DownloadPackageFileByName finds the version and serves the contents of a package
func DownloadPackageFileByName(ctx *context.Context) {
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{
OwnerID: ctx.Package.Owner.ID,
@@ -254,7 +254,7 @@ func DeletePreview(ctx *context.Context) {
// DeletePackageVersion deletes the package version
func DeletePackageVersion(ctx *context.Context) {
packageName := packageNameFromParams(ctx)
- packageVersion := ctx.Params("version")
+ packageVersion := ctx.PathParam("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
ctx,
@@ -349,7 +349,7 @@ func AddPackageTag(ctx *context.Context) {
return
}
- if err := setPackageTag(ctx, ctx.Params("tag"), pv, false); err != nil {
+ if err := setPackageTag(ctx, ctx.PathParam("tag"), pv, false); err != nil {
if err == errInvalidTagName {
apiError(ctx, http.StatusBadRequest, err)
return
@@ -370,7 +370,7 @@ func DeletePackageTag(ctx *context.Context) {
}
if len(pvs) != 0 {
- if err := setPackageTag(ctx, ctx.Params("tag"), pvs[0], true); err != nil {
+ if err := setPackageTag(ctx, ctx.PathParam("tag"), pvs[0], true); err != nil {
if err == errInvalidTagName {
apiError(ctx, http.StatusBadRequest, err)
return
diff --git a/routers/api/packages/nuget/nuget.go b/routers/api/packages/nuget/nuget.go
index 0d7212d7f7..70b95e6a77 100644
--- a/routers/api/packages/nuget/nuget.go
+++ b/routers/api/packages/nuget/nuget.go
@@ -226,7 +226,7 @@ func SearchServiceV3(ctx *context.Context) {
// https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-index
func RegistrationIndex(ctx *context.Context) {
- packageName := ctx.Params("id")
+ packageName := ctx.PathParam("id")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName)
if err != nil {
@@ -254,8 +254,8 @@ func RegistrationIndex(ctx *context.Context) {
// https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedQueryBuilder.cs
func RegistrationLeafV2(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName, packageVersion)
if err != nil {
@@ -283,8 +283,8 @@ func RegistrationLeafV2(ctx *context.Context) {
// https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-leaf
func RegistrationLeafV3(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := strings.TrimSuffix(ctx.Params("version"), ".json")
+ packageName := ctx.PathParam("id")
+ packageVersion := strings.TrimSuffix(ctx.PathParam("version"), ".json")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName, packageVersion)
if err != nil {
@@ -381,7 +381,7 @@ func EnumeratePackageVersionsV2Count(ctx *context.Context) {
// https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#enumerate-package-versions
func EnumeratePackageVersionsV3(ctx *context.Context) {
- packageName := ctx.Params("id")
+ packageName := ctx.PathParam("id")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName)
if err != nil {
@@ -401,9 +401,9 @@ func EnumeratePackageVersionsV3(ctx *context.Context) {
// https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-manifest-nuspec
// https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-content-nupkg
func DownloadPackageFile(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
- filename := ctx.Params("filename")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
+ filename := ctx.PathParam("filename")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
@@ -643,9 +643,9 @@ func processUploadedFile(ctx *context.Context, expectedType nuget_module.Package
// https://github.com/dotnet/symstore/blob/main/docs/specs/Simple_Symbol_Query_Protocol.md#request
func DownloadSymbolFile(ctx *context.Context) {
- filename := ctx.Params("filename")
- guid := ctx.Params("guid")[:32]
- filename2 := ctx.Params("filename2")
+ filename := ctx.PathParam("filename")
+ guid := ctx.PathParam("guid")[:32]
+ filename2 := ctx.PathParam("filename2")
if filename != filename2 {
apiError(ctx, http.StatusBadRequest, nil)
@@ -685,8 +685,8 @@ func DownloadSymbolFile(ctx *context.Context) {
// DeletePackage hard deletes the package
// https://docs.microsoft.com/en-us/nuget/api/package-publish-resource#delete-a-package
func DeletePackage(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
ctx,
diff --git a/routers/api/packages/pub/pub.go b/routers/api/packages/pub/pub.go
index f87df52a29..2be27323fd 100644
--- a/routers/api/packages/pub/pub.go
+++ b/routers/api/packages/pub/pub.go
@@ -81,7 +81,7 @@ func baseURL(ctx *context.Context) string {
// https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#list-all-versions-of-a-package
func EnumeratePackageVersions(ctx *context.Context) {
- packageName := ctx.Params("id")
+ packageName := ctx.PathParam("id")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName)
if err != nil {
@@ -119,8 +119,8 @@ func EnumeratePackageVersions(ctx *context.Context) {
// https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#deprecated-inspect-a-specific-version-of-a-package
func PackageVersionMetadata(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName, packageVersion)
if err != nil {
@@ -228,8 +228,8 @@ func UploadPackageFile(ctx *context.Context) {
// https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#publishing-packages
func FinalizePackage(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := ctx.Params("version")
+ packageName := ctx.PathParam("id")
+ packageVersion := ctx.PathParam("version")
_, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName, packageVersion)
if err != nil {
@@ -253,8 +253,8 @@ func FinalizePackage(ctx *context.Context) {
// https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#deprecated-download-a-specific-version-of-a-package
func DownloadPackageFile(ctx *context.Context) {
- packageName := ctx.Params("id")
- packageVersion := strings.TrimSuffix(ctx.Params("version"), ".tar.gz")
+ packageName := ctx.PathParam("id")
+ packageVersion := strings.TrimSuffix(ctx.PathParam("version"), ".tar.gz")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName, packageVersion)
if err != nil {
diff --git a/routers/api/packages/pypi/pypi.go b/routers/api/packages/pypi/pypi.go
index 7824db1823..5ea86071a9 100644
--- a/routers/api/packages/pypi/pypi.go
+++ b/routers/api/packages/pypi/pypi.go
@@ -45,7 +45,7 @@ func apiError(ctx *context.Context, status int, obj any) {
// PackageMetadata returns the metadata for a single package
func PackageMetadata(ctx *context.Context) {
- packageName := normalizer.Replace(ctx.Params("id"))
+ packageName := normalizer.Replace(ctx.PathParam("id"))
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypePyPI, packageName)
if err != nil {
@@ -76,9 +76,9 @@ func PackageMetadata(ctx *context.Context) {
// DownloadPackageFile serves the content of a package
func DownloadPackageFile(ctx *context.Context) {
- packageName := normalizer.Replace(ctx.Params("id"))
- packageVersion := ctx.Params("version")
- filename := ctx.Params("filename")
+ packageName := normalizer.Replace(ctx.PathParam("id"))
+ packageVersion := ctx.PathParam("version")
+ filename := ctx.PathParam("filename")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
diff --git a/routers/api/packages/rpm/rpm.go b/routers/api/packages/rpm/rpm.go
index c59366992c..11d7729eec 100644
--- a/routers/api/packages/rpm/rpm.go
+++ b/routers/api/packages/rpm/rpm.go
@@ -33,7 +33,7 @@ func apiError(ctx *context.Context, status int, obj any) {
// https://dnf.readthedocs.io/en/latest/conf_ref.html
func GetRepositoryConfig(ctx *context.Context) {
- group := ctx.Params("group")
+ group := ctx.PathParam("group")
var groupParts []string
if group != "" {
@@ -71,7 +71,7 @@ func CheckRepositoryFileExistence(ctx *context.Context) {
return
}
- pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.Params("filename"), ctx.Params("group"))
+ pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.PathParam("filename"), ctx.PathParam("group"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
ctx.Status(http.StatusNotFound)
@@ -100,8 +100,8 @@ func GetRepositoryFile(ctx *context.Context) {
ctx,
pv,
&packages_service.PackageFileInfo{
- Filename: ctx.Params("filename"),
- CompositeKey: ctx.Params("group"),
+ Filename: ctx.PathParam("filename"),
+ CompositeKey: ctx.PathParam("group"),
},
)
if err != nil {
@@ -153,7 +153,7 @@ func UploadPackageFile(ctx *context.Context) {
apiError(ctx, http.StatusInternalServerError, err)
return
}
- group := ctx.Params("group")
+ group := ctx.PathParam("group")
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
ctx,
&packages_service.PackageCreationInfo{
@@ -202,8 +202,8 @@ func UploadPackageFile(ctx *context.Context) {
}
func DownloadPackageFile(ctx *context.Context) {
- name := ctx.Params("name")
- version := ctx.Params("version")
+ name := ctx.PathParam("name")
+ version := ctx.PathParam("version")
s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion(
ctx,
@@ -214,8 +214,8 @@ func DownloadPackageFile(ctx *context.Context) {
Version: version,
},
&packages_service.PackageFileInfo{
- Filename: fmt.Sprintf("%s-%s.%s.rpm", name, version, ctx.Params("architecture")),
- CompositeKey: ctx.Params("group"),
+ Filename: fmt.Sprintf("%s-%s.%s.rpm", name, version, ctx.PathParam("architecture")),
+ CompositeKey: ctx.PathParam("group"),
},
)
if err != nil {
@@ -231,10 +231,10 @@ func DownloadPackageFile(ctx *context.Context) {
}
func DeletePackageFile(webctx *context.Context) {
- group := webctx.Params("group")
- name := webctx.Params("name")
- version := webctx.Params("version")
- architecture := webctx.Params("architecture")
+ group := webctx.PathParam("group")
+ name := webctx.PathParam("name")
+ version := webctx.PathParam("version")
+ architecture := webctx.PathParam("architecture")
var pd *packages_model.PackageDescriptor
diff --git a/routers/api/packages/rubygems/rubygems.go b/routers/api/packages/rubygems/rubygems.go
index 0a08378b47..958063e70a 100644
--- a/routers/api/packages/rubygems/rubygems.go
+++ b/routers/api/packages/rubygems/rubygems.go
@@ -95,7 +95,7 @@ func enumeratePackages(ctx *context.Context, filename string, pvs []*packages_mo
// ServePackageSpecification serves the compressed Gemspec file of a package
func ServePackageSpecification(ctx *context.Context) {
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
if !strings.HasSuffix(filename, ".gemspec.rz") {
apiError(ctx, http.StatusNotImplemented, nil)
@@ -164,7 +164,7 @@ func ServePackageSpecification(ctx *context.Context) {
// DownloadPackageFile serves the content of a package
func DownloadPackageFile(ctx *context.Context) {
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
pvs, err := getVersionsByFilename(ctx, filename)
if err != nil {
@@ -299,7 +299,7 @@ func DeletePackage(ctx *context.Context) {
// GetPackageInfo returns a custom text based format for the single rubygem with a line for each version of the rubygem
// ref: https://guides.rubygems.org/rubygems-org-compact-index-api/
func GetPackageInfo(ctx *context.Context) {
- packageName := ctx.Params("packagename")
+ packageName := ctx.PathParam("packagename")
versions, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems, packageName)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
diff --git a/routers/api/packages/swift/swift.go b/routers/api/packages/swift/swift.go
index a9da3ea9c2..d5d4d4e9d1 100644
--- a/routers/api/packages/swift/swift.go
+++ b/routers/api/packages/swift/swift.go
@@ -115,8 +115,8 @@ type EnumeratePackageVersionsResponse struct {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#41-list-package-releases
func EnumeratePackageVersions(ctx *context.Context) {
- packageScope := ctx.Params("scope")
- packageName := ctx.Params("name")
+ packageScope := ctx.PathParam("scope")
+ packageName := ctx.PathParam("name")
pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(packageScope, packageName))
if err != nil {
@@ -172,9 +172,9 @@ type PackageVersionMetadataResponse struct {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#endpoint-2
func PackageVersionMetadata(ctx *context.Context) {
- id := buildPackageID(ctx.Params("scope"), ctx.Params("name"))
+ id := buildPackageID(ctx.PathParam("scope"), ctx.PathParam("name"))
- pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, id, ctx.Params("version"))
+ pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, id, ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
@@ -230,9 +230,9 @@ func PackageVersionMetadata(ctx *context.Context) {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#43-fetch-manifest-for-a-package-release
func DownloadManifest(ctx *context.Context) {
- packageScope := ctx.Params("scope")
- packageName := ctx.Params("name")
- packageVersion := ctx.Params("version")
+ packageScope := ctx.PathParam("scope")
+ packageName := ctx.PathParam("name")
+ packageVersion := ctx.PathParam("version")
pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(packageScope, packageName), packageVersion)
if err != nil {
@@ -282,10 +282,10 @@ func DownloadManifest(ctx *context.Context) {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#endpoint-6
func UploadPackageFile(ctx *context.Context) {
- packageScope := ctx.Params("scope")
- packageName := ctx.Params("name")
+ packageScope := ctx.PathParam("scope")
+ packageName := ctx.PathParam("name")
- v, err := version.NewVersion(ctx.Params("version"))
+ v, err := version.NewVersion(ctx.PathParam("version"))
if !scopePattern.MatchString(packageScope) || !namePattern.MatchString(packageName) || err != nil {
apiError(ctx, http.StatusBadRequest, err)
@@ -381,7 +381,7 @@ func UploadPackageFile(ctx *context.Context) {
// https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#endpoint-4
func DownloadPackageFile(ctx *context.Context) {
- pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(ctx.Params("scope"), ctx.Params("name")), ctx.Params("version"))
+ pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(ctx.PathParam("scope"), ctx.PathParam("name")), ctx.PathParam("version"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
diff --git a/routers/api/packages/vagrant/vagrant.go b/routers/api/packages/vagrant/vagrant.go
index 98a81da368..1daf2a0527 100644
--- a/routers/api/packages/vagrant/vagrant.go
+++ b/routers/api/packages/vagrant/vagrant.go
@@ -44,7 +44,7 @@ func CheckAuthenticate(ctx *context.Context) {
}
func CheckBoxAvailable(ctx *context.Context) {
- pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.Params("name"))
+ pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.PathParam("name"))
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -101,7 +101,7 @@ func packageDescriptorToMetadata(baseURL string, pd *packages_model.PackageDescr
}
func EnumeratePackageVersions(ctx *context.Context) {
- pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.Params("name"))
+ pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.PathParam("name"))
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -136,14 +136,14 @@ func EnumeratePackageVersions(ctx *context.Context) {
}
func UploadPackageFile(ctx *context.Context) {
- boxName := ctx.Params("name")
- boxVersion := ctx.Params("version")
+ boxName := ctx.PathParam("name")
+ boxVersion := ctx.PathParam("version")
_, err := version.NewSemver(boxVersion)
if err != nil {
apiError(ctx, http.StatusBadRequest, err)
return
}
- boxProvider := ctx.Params("provider")
+ boxProvider := ctx.PathParam("provider")
if !strings.HasSuffix(boxProvider, ".box") {
apiError(ctx, http.StatusBadRequest, err)
return
@@ -222,11 +222,11 @@ func DownloadPackageFile(ctx *context.Context) {
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
PackageType: packages_model.TypeVagrant,
- Name: ctx.Params("name"),
- Version: ctx.Params("version"),
+ Name: ctx.PathParam("name"),
+ Version: ctx.PathParam("version"),
},
&packages_service.PackageFileInfo{
- Filename: ctx.Params("provider"),
+ Filename: ctx.PathParam("provider"),
},
)
if err != nil {
diff --git a/routers/api/v1/admin/adopt.go b/routers/api/v1/admin/adopt.go
index a4708fe032..613d123494 100644
--- a/routers/api/v1/admin/adopt.go
+++ b/routers/api/v1/admin/adopt.go
@@ -80,8 +80,8 @@ func AdoptRepository(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
// "403":
// "$ref": "#/responses/forbidden"
- ownerName := ctx.Params(":username")
- repoName := ctx.Params(":reponame")
+ ownerName := ctx.PathParam(":username")
+ repoName := ctx.PathParam(":reponame")
ctxUser, err := user_model.GetUserByName(ctx, ownerName)
if err != nil {
@@ -142,8 +142,8 @@ func DeleteUnadoptedRepository(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "403":
// "$ref": "#/responses/forbidden"
- ownerName := ctx.Params(":username")
- repoName := ctx.Params(":reponame")
+ ownerName := ctx.PathParam(":username")
+ repoName := ctx.PathParam(":reponame")
ctxUser, err := user_model.GetUserByName(ctx, ownerName)
if err != nil {
diff --git a/routers/api/v1/admin/cron.go b/routers/api/v1/admin/cron.go
index e1ca6048c9..fba9d33f25 100644
--- a/routers/api/v1/admin/cron.go
+++ b/routers/api/v1/admin/cron.go
@@ -74,7 +74,7 @@ func PostCronTask(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
- task := cron.GetTask(ctx.Params(":task"))
+ task := cron.GetTask(ctx.PathParam(":task"))
if task == nil {
ctx.NotFound()
return
diff --git a/routers/api/v1/admin/email.go b/routers/api/v1/admin/email.go
index ba963e9f69..6fe418249b 100644
--- a/routers/api/v1/admin/email.go
+++ b/routers/api/v1/admin/email.go
@@ -38,7 +38,7 @@ func GetAllEmails(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx)
emails, maxResults, err := user_model.SearchEmails(ctx, &user_model.SearchEmailOptions{
- Keyword: ctx.Params(":email"),
+ Keyword: ctx.PathParam(":email"),
ListOptions: listOptions,
})
if err != nil {
@@ -82,6 +82,6 @@ func SearchEmail(ctx *context.APIContext) {
// "403":
// "$ref": "#/responses/forbidden"
- ctx.SetParams(":email", ctx.FormTrim("q"))
+ ctx.SetPathParam(":email", ctx.FormTrim("q"))
GetAllEmails(ctx)
}
diff --git a/routers/api/v1/admin/hooks.go b/routers/api/v1/admin/hooks.go
index 4c168b55bf..fa60836b7e 100644
--- a/routers/api/v1/admin/hooks.go
+++ b/routers/api/v1/admin/hooks.go
@@ -73,7 +73,7 @@ func GetHook(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/Hook"
- hookID := ctx.ParamsInt64(":id")
+ hookID := ctx.PathParamInt64(":id")
hook, err := webhook.GetSystemOrDefaultWebhook(ctx, hookID)
if err != nil {
if errors.Is(err, util.ErrNotExist) {
@@ -142,7 +142,7 @@ func EditHook(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.EditHookOption)
// TODO in body params
- hookID := ctx.ParamsInt64(":id")
+ hookID := ctx.PathParamInt64(":id")
utils.EditSystemHook(ctx, form, hookID)
}
@@ -164,7 +164,7 @@ func DeleteHook(ctx *context.APIContext) {
// "204":
// "$ref": "#/responses/empty"
- hookID := ctx.ParamsInt64(":id")
+ hookID := ctx.PathParamInt64(":id")
if err := webhook.DeleteDefaultSystemWebhook(ctx, hookID); err != nil {
if errors.Is(err, util.ErrNotExist) {
ctx.NotFound()
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go
index be907805d6..3e2fefc6da 100644
--- a/routers/api/v1/admin/user.go
+++ b/routers/api/v1/admin/user.go
@@ -373,7 +373,7 @@ func DeleteUserPublicKey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := asymkey_service.DeletePublicKey(ctx, ctx.ContextUser, ctx.ParamsInt64(":id")); err != nil {
+ if err := asymkey_service.DeletePublicKey(ctx, ctx.ContextUser, ctx.PathParamInt64(":id")); err != nil {
if asymkey_model.IsErrKeyNotExist(err) {
ctx.NotFound()
} else if asymkey_model.IsErrKeyAccessDenied(err) {
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 5363489939..be67ec1695 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -136,8 +136,8 @@ func sudo() func(ctx *context.APIContext) {
func repoAssignment() func(ctx *context.APIContext) {
return func(ctx *context.APIContext) {
- userName := ctx.Params("username")
- repoName := ctx.Params("reponame")
+ userName := ctx.PathParam("username")
+ repoName := ctx.PathParam("reponame")
var (
owner *user_model.User
@@ -555,12 +555,12 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) {
var err error
if assignOrg {
- ctx.Org.Organization, err = organization.GetOrgByName(ctx, ctx.Params(":org"))
+ ctx.Org.Organization, err = organization.GetOrgByName(ctx, ctx.PathParam(":org"))
if err != nil {
if organization.IsErrOrgNotExist(err) {
- redirectUserID, err := user_model.LookupUserRedirect(ctx, ctx.Params(":org"))
+ redirectUserID, err := user_model.LookupUserRedirect(ctx, ctx.PathParam(":org"))
if err == nil {
- context.RedirectToUser(ctx.Base, ctx.Params(":org"), redirectUserID)
+ context.RedirectToUser(ctx.Base, ctx.PathParam(":org"), redirectUserID)
} else if user_model.IsErrUserRedirectNotExist(err) {
ctx.NotFound("GetOrgByName", err)
} else {
@@ -575,7 +575,7 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) {
}
if assignTeam {
- ctx.Org.Team, err = organization.GetTeamByID(ctx, ctx.ParamsInt64(":teamid"))
+ ctx.Org.Team, err = organization.GetTeamByID(ctx, ctx.PathParamInt64(":teamid"))
if err != nil {
if organization.IsErrTeamNotExist(err) {
ctx.NotFound()
@@ -812,8 +812,8 @@ func checkDeprecatedAuthMethods(ctx *context.APIContext) {
}
// Routes registers all v1 APIs routes to web application.
-func Routes() *web.Route {
- m := web.NewRoute()
+func Routes() *web.Router {
+ m := web.NewRouter()
m.Use(securityHeaders())
if setting.CORSConfig.Enabled {
@@ -837,7 +837,7 @@ func Routes() *web.Route {
}))
addActionsRoutes := func(
- m *web.Route,
+ m *web.Router,
reqChecker func(ctx *context.APIContext),
act actions.API,
) {
diff --git a/routers/api/v1/misc/gitignore.go b/routers/api/v1/misc/gitignore.go
index dffd771752..b0bf00a921 100644
--- a/routers/api/v1/misc/gitignore.go
+++ b/routers/api/v1/misc/gitignore.go
@@ -44,7 +44,7 @@ func GetGitignoreTemplateInfo(ctx *context.APIContext) {
// "$ref": "#/responses/GitignoreTemplateInfo"
// "404":
// "$ref": "#/responses/notFound"
- name := util.PathJoinRelX(ctx.Params("name"))
+ name := util.PathJoinRelX(ctx.PathParam("name"))
text, err := options.Gitignore(name)
if err != nil {
diff --git a/routers/api/v1/misc/label_templates.go b/routers/api/v1/misc/label_templates.go
index cc11f37626..f105b4c684 100644
--- a/routers/api/v1/misc/label_templates.go
+++ b/routers/api/v1/misc/label_templates.go
@@ -48,7 +48,7 @@ func GetLabelTemplate(ctx *context.APIContext) {
// "$ref": "#/responses/LabelTemplateInfo"
// "404":
// "$ref": "#/responses/notFound"
- name := util.PathJoinRelX(ctx.Params("name"))
+ name := util.PathJoinRelX(ctx.PathParam("name"))
labels, err := repo_module.LoadTemplateLabelsByDisplayName(name)
if err != nil {
diff --git a/routers/api/v1/misc/licenses.go b/routers/api/v1/misc/licenses.go
index 2a980f5084..d99b276232 100644
--- a/routers/api/v1/misc/licenses.go
+++ b/routers/api/v1/misc/licenses.go
@@ -55,7 +55,7 @@ func GetLicenseTemplateInfo(ctx *context.APIContext) {
// "$ref": "#/responses/LicenseTemplateInfo"
// "404":
// "$ref": "#/responses/notFound"
- name := util.PathJoinRelX(ctx.Params("name"))
+ name := util.PathJoinRelX(ctx.PathParam("name"))
text, err := options.License(name)
if err != nil {
diff --git a/routers/api/v1/notify/threads.go b/routers/api/v1/notify/threads.go
index 8e12d359cb..0761e684a3 100644
--- a/routers/api/v1/notify/threads.go
+++ b/routers/api/v1/notify/threads.go
@@ -101,7 +101,7 @@ func ReadThread(ctx *context.APIContext) {
}
func getThread(ctx *context.APIContext) *activities_model.Notification {
- n, err := activities_model.GetNotificationByID(ctx, ctx.ParamsInt64(":id"))
+ n, err := activities_model.GetNotificationByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if db.IsErrNotExist(err) {
ctx.Error(http.StatusNotFound, "GetNotificationByID", err)
diff --git a/routers/api/v1/org/action.go b/routers/api/v1/org/action.go
index 03a1fa8ccc..199ee7d777 100644
--- a/routers/api/v1/org/action.go
+++ b/routers/api/v1/org/action.go
@@ -106,7 +106,7 @@ func (Action) CreateOrUpdateSecret(ctx *context.APIContext) {
opt := web.GetForm(ctx).(*api.CreateOrUpdateSecretOption)
- _, created, err := secret_service.CreateOrUpdateSecret(ctx, ctx.Org.Organization.ID, 0, ctx.Params("secretname"), opt.Data)
+ _, created, err := secret_service.CreateOrUpdateSecret(ctx, ctx.Org.Organization.ID, 0, ctx.PathParam("secretname"), opt.Data)
if err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "CreateOrUpdateSecret", err)
@@ -153,7 +153,7 @@ func (Action) DeleteSecret(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- err := secret_service.DeleteSecretByName(ctx, ctx.Org.Organization.ID, 0, ctx.Params("secretname"))
+ err := secret_service.DeleteSecretByName(ctx, ctx.Org.Organization.ID, 0, ctx.PathParam("secretname"))
if err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "DeleteSecret", err)
@@ -269,7 +269,7 @@ func (Action) GetVariable(ctx *context.APIContext) {
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
OwnerID: ctx.Org.Organization.ID,
- Name: ctx.Params("variablename"),
+ Name: ctx.PathParam("variablename"),
})
if err != nil {
if errors.Is(err, util.ErrNotExist) {
@@ -320,7 +320,7 @@ func (Action) DeleteVariable(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := actions_service.DeleteVariableByName(ctx, ctx.Org.Organization.ID, 0, ctx.Params("variablename")); err != nil {
+ if err := actions_service.DeleteVariableByName(ctx, ctx.Org.Organization.ID, 0, ctx.PathParam("variablename")); err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "DeleteVariableByName", err)
} else if errors.Is(err, util.ErrNotExist) {
@@ -371,7 +371,7 @@ func (Action) CreateVariable(ctx *context.APIContext) {
opt := web.GetForm(ctx).(*api.CreateVariableOption)
ownerID := ctx.Org.Organization.ID
- variableName := ctx.Params("variablename")
+ variableName := ctx.PathParam("variablename")
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
OwnerID: ownerID,
@@ -436,7 +436,7 @@ func (Action) UpdateVariable(ctx *context.APIContext) {
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
OwnerID: ctx.Org.Organization.ID,
- Name: ctx.Params("variablename"),
+ Name: ctx.PathParam("variablename"),
})
if err != nil {
if errors.Is(err, util.ErrNotExist) {
@@ -448,7 +448,7 @@ func (Action) UpdateVariable(ctx *context.APIContext) {
}
if opt.Name == "" {
- opt.Name = ctx.Params("variablename")
+ opt.Name = ctx.PathParam("variablename")
}
if _, err := actions_service.UpdateVariable(ctx, v.ID, opt.Name, opt.Value); err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go
index c1dc0519ea..df82f4e5a2 100644
--- a/routers/api/v1/org/hook.go
+++ b/routers/api/v1/org/hook.go
@@ -71,7 +71,7 @@ func GetHook(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- hook, err := utils.GetOwnerHook(ctx, ctx.ContextUser.ID, ctx.ParamsInt64("id"))
+ hook, err := utils.GetOwnerHook(ctx, ctx.ContextUser.ID, ctx.PathParamInt64("id"))
if err != nil {
return
}
@@ -152,7 +152,7 @@ func EditHook(ctx *context.APIContext) {
ctx,
ctx.ContextUser,
web.GetForm(ctx).(*api.EditHookOption),
- ctx.ParamsInt64("id"),
+ ctx.PathParamInt64("id"),
)
}
@@ -184,6 +184,6 @@ func DeleteHook(ctx *context.APIContext) {
utils.DeleteOwnerHook(
ctx,
ctx.ContextUser,
- ctx.ParamsInt64("id"),
+ ctx.PathParamInt64("id"),
)
}
diff --git a/routers/api/v1/org/label.go b/routers/api/v1/org/label.go
index b5ec54ccf4..24ee4ed642 100644
--- a/routers/api/v1/org/label.go
+++ b/routers/api/v1/org/label.go
@@ -139,7 +139,7 @@ func GetLabel(ctx *context.APIContext) {
label *issues_model.Label
err error
)
- strID := ctx.Params(":id")
+ strID := ctx.PathParam(":id")
if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil {
label, err = issues_model.GetLabelInOrgByName(ctx, ctx.Org.Organization.ID, strID)
} else {
@@ -190,7 +190,7 @@ func EditLabel(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.EditLabelOption)
- l, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.ParamsInt64(":id"))
+ l, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64(":id"))
if err != nil {
if issues_model.IsErrOrgLabelNotExist(err) {
ctx.NotFound()
@@ -249,7 +249,7 @@ func DeleteLabel(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := issues_model.DeleteLabel(ctx, ctx.Org.Organization.ID, ctx.ParamsInt64(":id")); err != nil {
+ if err := issues_model.DeleteLabel(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64(":id")); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteLabel", err)
return
}
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index 015af774e3..c55837ff44 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -453,7 +453,7 @@ func GetTeamMember(ctx *context.APIContext) {
if ctx.Written() {
return
}
- teamID := ctx.ParamsInt64("teamid")
+ teamID := ctx.PathParamInt64("teamid")
isTeamMember, err := organization.IsUserInTeams(ctx, u.ID, []int64{teamID})
if err != nil {
ctx.Error(http.StatusInternalServerError, "IsUserInTeams", err)
@@ -645,7 +645,7 @@ func GetTeamRepo(ctx *context.APIContext) {
// getRepositoryByParams get repository by a team's organization ID and repo name
func getRepositoryByParams(ctx *context.APIContext) *repo_model.Repository {
- repo, err := repo_model.GetRepositoryByName(ctx, ctx.Org.Team.OrgID, ctx.Params(":reponame"))
+ repo, err := repo_model.GetRepositoryByName(ctx, ctx.Org.Team.OrgID, ctx.PathParam(":reponame"))
if err != nil {
if repo_model.IsErrRepoNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/action.go b/routers/api/v1/repo/action.go
index f6656d89c6..48ba35ac21 100644
--- a/routers/api/v1/repo/action.go
+++ b/routers/api/v1/repo/action.go
@@ -122,7 +122,7 @@ func (Action) CreateOrUpdateSecret(ctx *context.APIContext) {
opt := web.GetForm(ctx).(*api.CreateOrUpdateSecretOption)
- _, created, err := secret_service.CreateOrUpdateSecret(ctx, owner.ID, repo.ID, ctx.Params("secretname"), opt.Data)
+ _, created, err := secret_service.CreateOrUpdateSecret(ctx, owner.ID, repo.ID, ctx.PathParam("secretname"), opt.Data)
if err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "CreateOrUpdateSecret", err)
@@ -177,7 +177,7 @@ func (Action) DeleteSecret(ctx *context.APIContext) {
owner := ctx.Repo.Owner
repo := ctx.Repo.Repository
- err := secret_service.DeleteSecretByName(ctx, owner.ID, repo.ID, ctx.Params("secretname"))
+ err := secret_service.DeleteSecretByName(ctx, owner.ID, repo.ID, ctx.PathParam("secretname"))
if err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "DeleteSecret", err)
@@ -224,7 +224,7 @@ func (Action) GetVariable(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
RepoID: ctx.Repo.Repository.ID,
- Name: ctx.Params("variablename"),
+ Name: ctx.PathParam("variablename"),
})
if err != nil {
if errors.Is(err, util.ErrNotExist) {
@@ -280,7 +280,7 @@ func (Action) DeleteVariable(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := actions_service.DeleteVariableByName(ctx, 0, ctx.Repo.Repository.ID, ctx.Params("variablename")); err != nil {
+ if err := actions_service.DeleteVariableByName(ctx, 0, ctx.Repo.Repository.ID, ctx.PathParam("variablename")); err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "DeleteVariableByName", err)
} else if errors.Is(err, util.ErrNotExist) {
@@ -334,7 +334,7 @@ func (Action) CreateVariable(ctx *context.APIContext) {
opt := web.GetForm(ctx).(*api.CreateVariableOption)
repoID := ctx.Repo.Repository.ID
- variableName := ctx.Params("variablename")
+ variableName := ctx.PathParam("variablename")
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
RepoID: repoID,
@@ -402,7 +402,7 @@ func (Action) UpdateVariable(ctx *context.APIContext) {
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
RepoID: ctx.Repo.Repository.ID,
- Name: ctx.Params("variablename"),
+ Name: ctx.PathParam("variablename"),
})
if err != nil {
if errors.Is(err, util.ErrNotExist) {
@@ -414,7 +414,7 @@ func (Action) UpdateVariable(ctx *context.APIContext) {
}
if opt.Name == "" {
- opt.Name = ctx.Params("variablename")
+ opt.Name = ctx.PathParam("variablename")
}
if _, err := actions_service.UpdateVariable(ctx, v.ID, opt.Name, opt.Value); err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
diff --git a/routers/api/v1/repo/blob.go b/routers/api/v1/repo/blob.go
index 3b116666ea..f38086954b 100644
--- a/routers/api/v1/repo/blob.go
+++ b/routers/api/v1/repo/blob.go
@@ -41,7 +41,7 @@ func GetBlob(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- sha := ctx.Params("sha")
+ sha := ctx.PathParam("sha")
if len(sha) == 0 {
ctx.Error(http.StatusBadRequest, "", "sha not provided")
return
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go
index baab486e52..652fcd9441 100644
--- a/routers/api/v1/repo/branch.go
+++ b/routers/api/v1/repo/branch.go
@@ -56,7 +56,7 @@ func GetBranch(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- branchName := ctx.Params("*")
+ branchName := ctx.PathParam("*")
branch, err := ctx.Repo.GitRepo.GetBranch(branchName)
if err != nil {
@@ -131,7 +131,7 @@ func DeleteBranch(ctx *context.APIContext) {
return
}
- branchName := ctx.Params("*")
+ branchName := ctx.PathParam("*")
if ctx.Repo.Repository.IsEmpty {
ctx.Error(http.StatusForbidden, "", "Git Repository is empty.")
@@ -426,7 +426,7 @@ func GetBranchProtection(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
repo := ctx.Repo.Repository
- bpName := ctx.Params(":name")
+ bpName := ctx.PathParam(":name")
bp, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
@@ -724,7 +724,7 @@ func EditBranchProtection(ctx *context.APIContext) {
// "$ref": "#/responses/repoArchivedError"
form := web.GetForm(ctx).(*api.EditBranchProtectionOption)
repo := ctx.Repo.Repository
- bpName := ctx.Params(":name")
+ bpName := ctx.PathParam(":name")
protectBranch, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
@@ -992,7 +992,7 @@ func DeleteBranchProtection(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
repo := ctx.Repo.Repository
- bpName := ctx.Params(":name")
+ bpName := ctx.PathParam(":name")
bp, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go
index 4ce14f7d01..39c9ba527d 100644
--- a/routers/api/v1/repo/collaborators.go
+++ b/routers/api/v1/repo/collaborators.go
@@ -102,7 +102,7 @@ func IsCollaborator(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
- user, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator"))
+ user, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -162,7 +162,7 @@ func AddCollaborator(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.AddCollaboratorOption)
- collaborator, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator"))
+ collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -227,7 +227,7 @@ func DeleteCollaborator(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
- collaborator, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator"))
+ collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -275,12 +275,12 @@ func GetRepoPermissions(ctx *context.APIContext) {
// "403":
// "$ref": "#/responses/forbidden"
- if !ctx.Doer.IsAdmin && ctx.Doer.LoginName != ctx.Params(":collaborator") && !ctx.IsUserRepoAdmin() {
+ if !ctx.Doer.IsAdmin && ctx.Doer.LoginName != ctx.PathParam(":collaborator") && !ctx.IsUserRepoAdmin() {
ctx.Error(http.StatusForbidden, "User", "Only admins can query all permissions, repo admins can query all repo permissions, collaborators can query only their own")
return
}
- collaborator, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator"))
+ collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusNotFound, "GetUserByName", err)
diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go
index d06a3b4e49..d33be9d80a 100644
--- a/routers/api/v1/repo/commits.go
+++ b/routers/api/v1/repo/commits.go
@@ -63,7 +63,7 @@ func GetSingleCommit(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- sha := ctx.Params(":sha")
+ sha := ctx.PathParam(":sha")
if !git.IsValidRefPattern(sha) {
ctx.Error(http.StatusUnprocessableEntity, "no valid ref or sha", fmt.Sprintf("no valid ref or sha: %s", sha))
return
@@ -312,8 +312,8 @@ func DownloadCommitDiffOrPatch(ctx *context.APIContext) {
// "$ref": "#/responses/string"
// "404":
// "$ref": "#/responses/notFound"
- sha := ctx.Params(":sha")
- diffType := git.RawDiffType(ctx.Params(":diffType"))
+ sha := ctx.PathParam(":sha")
+ diffType := git.RawDiffType(ctx.PathParam(":diffType"))
if err := git.GetRawDiff(ctx.Repo.GitRepo, sha, diffType, ctx.Resp); err != nil {
if git.IsErrNotExist(err) {
@@ -354,7 +354,7 @@ func GetCommitPullRequest(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- pr, err := issues_model.GetPullRequestByMergedCommit(ctx, ctx.Repo.Repository.ID, ctx.Params(":sha"))
+ pr, err := issues_model.GetPullRequestByMergedCommit(ctx, ctx.Repo.Repository.ID, ctx.PathParam(":sha"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.Error(http.StatusNotFound, "GetPullRequestByMergedCommit", err)
diff --git a/routers/api/v1/repo/compare.go b/routers/api/v1/repo/compare.go
index 429145c714..38e5330b3a 100644
--- a/routers/api/v1/repo/compare.go
+++ b/routers/api/v1/repo/compare.go
@@ -53,7 +53,7 @@ func CompareDiff(ctx *context.APIContext) {
defer gitRepo.Close()
}
- infoPath := ctx.Params("*")
+ infoPath := ctx.PathParam("*")
infos := []string{ctx.Repo.Repository.DefaultBranch, ctx.Repo.Repository.DefaultBranch}
if infoPath != "" {
infos = strings.SplitN(infoPath, "...", 2)
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index 6ecdc1ff67..42483291fc 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -294,7 +294,7 @@ func GetArchive(ctx *context.APIContext) {
}
func archiveDownload(ctx *context.APIContext) {
- uri := ctx.Params("*")
+ uri := ctx.PathParam("*")
aReq, err := archiver_service.NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, uri)
if err != nil {
if errors.Is(err, archiver_service.ErrUnknownArchiveFormat{}) {
@@ -393,7 +393,7 @@ func GetEditorconfig(ctx *context.APIContext) {
return
}
- fileName := ctx.Params("filename")
+ fileName := ctx.PathParam("filename")
def, err := ec.GetDefinitionForFilename(fileName)
if def == nil {
ctx.NotFound(err)
@@ -577,7 +577,7 @@ func CreateFile(ctx *context.APIContext) {
Files: []*files_service.ChangeRepoFile{
{
Operation: "create",
- TreePath: ctx.Params("*"),
+ TreePath: ctx.PathParam("*"),
ContentReader: contentReader,
},
},
@@ -681,7 +681,7 @@ func UpdateFile(ctx *context.APIContext) {
ContentReader: contentReader,
SHA: apiOpts.SHA,
FromTreePath: apiOpts.FromPath,
- TreePath: ctx.Params("*"),
+ TreePath: ctx.PathParam("*"),
},
},
Message: apiOpts.Message,
@@ -840,7 +840,7 @@ func DeleteFile(ctx *context.APIContext) {
{
Operation: "delete",
SHA: apiOpts.SHA,
- TreePath: ctx.Params("*"),
+ TreePath: ctx.PathParam("*"),
},
},
Message: apiOpts.Message,
@@ -935,7 +935,7 @@ func GetContents(ctx *context.APIContext) {
return
}
- treePath := ctx.Params("*")
+ treePath := ctx.PathParam("*")
ref := ctx.FormTrim("ref")
if fileList, err := files_service.GetContentsOrList(ctx, ctx.Repo.Repository, treePath, ref); err != nil {
diff --git a/routers/api/v1/repo/git_hook.go b/routers/api/v1/repo/git_hook.go
index 26ae84d08d..0887a90096 100644
--- a/routers/api/v1/repo/git_hook.go
+++ b/routers/api/v1/repo/git_hook.go
@@ -79,7 +79,7 @@ func GetGitHook(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- hookID := ctx.Params(":id")
+ hookID := ctx.PathParam(":id")
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
if err != nil {
if err == git.ErrNotValidHook {
@@ -126,7 +126,7 @@ func EditGitHook(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.EditGitHookOption)
- hookID := ctx.Params(":id")
+ hookID := ctx.PathParam(":id")
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
if err != nil {
if err == git.ErrNotValidHook {
@@ -175,7 +175,7 @@ func DeleteGitHook(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- hookID := ctx.Params(":id")
+ hookID := ctx.PathParam(":id")
hook, err := ctx.Repo.GitRepo.GetHook(hookID)
if err != nil {
if err == git.ErrNotValidHook {
diff --git a/routers/api/v1/repo/git_ref.go b/routers/api/v1/repo/git_ref.go
index 0fa58425b8..1743c0fc20 100644
--- a/routers/api/v1/repo/git_ref.go
+++ b/routers/api/v1/repo/git_ref.go
@@ -71,7 +71,7 @@ func GetGitRefs(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- getGitRefsInternal(ctx, ctx.Params("*"))
+ getGitRefsInternal(ctx, ctx.PathParam("*"))
}
func getGitRefsInternal(ctx *context.APIContext, filter string) {
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go
index ffd2313591..9ef57da1b9 100644
--- a/routers/api/v1/repo/hook.go
+++ b/routers/api/v1/repo/hook.go
@@ -109,7 +109,7 @@ func GetHook(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
repo := ctx.Repo
- hookID := ctx.ParamsInt64(":id")
+ hookID := ctx.PathParamInt64(":id")
hook, err := utils.GetRepoHook(ctx, repo.Repository.ID, hookID)
if err != nil {
return
@@ -168,7 +168,7 @@ func TestHook(ctx *context.APIContext) {
ref = r
}
- hookID := ctx.ParamsInt64(":id")
+ hookID := ctx.PathParamInt64(":id")
hook, err := utils.GetRepoHook(ctx, ctx.Repo.Repository.ID, hookID)
if err != nil {
return
@@ -263,7 +263,7 @@ func EditHook(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.EditHookOption)
- hookID := ctx.ParamsInt64(":id")
+ hookID := ctx.PathParamInt64(":id")
utils.EditRepoHook(ctx, form, hookID)
}
@@ -296,7 +296,7 @@ func DeleteHook(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
- if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
+ if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id")); err != nil {
if webhook.IsErrWebhookNotExist(err) {
ctx.NotFound()
} else {
diff --git a/routers/api/v1/repo/hook_test.go b/routers/api/v1/repo/hook_test.go
index 37cf61c1ed..c2f3a972ef 100644
--- a/routers/api/v1/repo/hook_test.go
+++ b/routers/api/v1/repo/hook_test.go
@@ -18,7 +18,7 @@ func TestTestHook(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1/wiki/_pages")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index ddfc36f17d..108504ebb4 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -599,7 +599,7 @@ func GetIssue(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -779,7 +779,7 @@ func EditIssue(ctx *context.APIContext) {
// "$ref": "#/responses/error"
form := web.GetForm(ctx).(*api.EditIssueOption)
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -942,7 +942,7 @@ func DeleteIssue(ctx *context.APIContext) {
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound(err)
@@ -998,7 +998,7 @@ func UpdateIssueDeadline(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.EditDeadlineOption)
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/issue_attachment.go b/routers/api/v1/repo/issue_attachment.go
index ef846a43a3..27c7af2282 100644
--- a/routers/api/v1/repo/issue_attachment.go
+++ b/routers/api/v1/repo/issue_attachment.go
@@ -320,7 +320,7 @@ func DeleteIssueAttachment(ctx *context.APIContext) {
}
func getIssueFromContext(ctx *context.APIContext) *issues_model.Issue {
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64("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
@@ -345,7 +345,7 @@ func getIssueAttachmentSafeWrite(ctx *context.APIContext) *repo_model.Attachment
}
func getIssueAttachmentSafeRead(ctx *context.APIContext, issue *issues_model.Issue) *repo_model.Attachment {
- attachment, err := repo_model.GetAttachmentByID(ctx, ctx.ParamsInt64("attachment_id"))
+ attachment, err := repo_model.GetAttachmentByID(ctx, ctx.PathParamInt64("attachment_id"))
if err != nil {
ctx.NotFoundOrServerError("GetAttachmentByID", repo_model.IsErrAttachmentNotExist, err)
return nil
diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go
index 910cc1ce74..f9b5aa816b 100644
--- a/routers/api/v1/repo/issue_comment.go
+++ b/routers/api/v1/repo/issue_comment.go
@@ -68,7 +68,7 @@ func ListIssueComments(ctx *context.APIContext) {
ctx.Error(http.StatusUnprocessableEntity, "GetQueryBeforeSince", err)
return
}
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetRawIssueByIndex", err)
return
@@ -172,7 +172,7 @@ func ListIssueCommentsAndTimeline(ctx *context.APIContext) {
ctx.Error(http.StatusUnprocessableEntity, "GetQueryBeforeSince", err)
return
}
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetRawIssueByIndex", err)
return
@@ -380,7 +380,7 @@ func CreateIssueComment(ctx *context.APIContext) {
// "$ref": "#/responses/repoArchivedError"
form := web.GetForm(ctx).(*api.CreateIssueCommentOption)
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetIssueByIndex", err)
return
@@ -445,7 +445,7 @@ func GetIssueComment(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if issues_model.IsErrCommentNotExist(err) {
ctx.NotFound(err)
@@ -579,7 +579,7 @@ func EditIssueCommentDeprecated(ctx *context.APIContext) {
}
func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) {
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if issues_model.IsErrCommentNotExist(err) {
ctx.NotFound(err)
@@ -696,7 +696,7 @@ func DeleteIssueCommentDeprecated(ctx *context.APIContext) {
}
func deleteIssueComment(ctx *context.APIContext) {
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if issues_model.IsErrCommentNotExist(err) {
ctx.NotFound(err)
diff --git a/routers/api/v1/repo/issue_comment_attachment.go b/routers/api/v1/repo/issue_comment_attachment.go
index 1ec758ec2c..0863ebd182 100644
--- a/routers/api/v1/repo/issue_comment_attachment.go
+++ b/routers/api/v1/repo/issue_comment_attachment.go
@@ -331,7 +331,7 @@ func DeleteIssueCommentAttachment(ctx *context.APIContext) {
}
func getIssueCommentSafe(ctx *context.APIContext) *issues_model.Comment {
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64("id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err)
return nil
@@ -376,7 +376,7 @@ func canUserWriteIssueCommentAttachment(ctx *context.APIContext, comment *issues
}
func getIssueCommentAttachmentSafeRead(ctx *context.APIContext, comment *issues_model.Comment) *repo_model.Attachment {
- attachment, err := repo_model.GetAttachmentByID(ctx, ctx.ParamsInt64("attachment_id"))
+ attachment, err := repo_model.GetAttachmentByID(ctx, ctx.PathParamInt64("attachment_id"))
if err != nil {
ctx.NotFoundOrServerError("GetAttachmentByID", repo_model.IsErrAttachmentNotExist, err)
return nil
diff --git a/routers/api/v1/repo/issue_dependency.go b/routers/api/v1/repo/issue_dependency.go
index c40e92c01b..712c71a682 100644
--- a/routers/api/v1/repo/issue_dependency.go
+++ b/routers/api/v1/repo/issue_dependency.go
@@ -61,7 +61,7 @@ func GetIssueDependencies(ctx *context.APIContext) {
return
}
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound("IsErrIssueNotExist", err)
@@ -499,7 +499,7 @@ func RemoveIssueBlocking(ctx *context.APIContext) {
}
func getParamsIssue(ctx *context.APIContext) *issues_model.Issue {
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound("IsErrIssueNotExist", err)
diff --git a/routers/api/v1/repo/issue_label.go b/routers/api/v1/repo/issue_label.go
index 413693c5ed..2f5ea8931b 100644
--- a/routers/api/v1/repo/issue_label.go
+++ b/routers/api/v1/repo/issue_label.go
@@ -47,7 +47,7 @@ func ListIssueLabels(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -163,7 +163,7 @@ func DeleteIssueLabel(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -178,7 +178,7 @@ func DeleteIssueLabel(ctx *context.APIContext) {
return
}
- label, err := issues_model.GetLabelByID(ctx, ctx.ParamsInt64(":id"))
+ label, err := issues_model.GetLabelByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if issues_model.IsErrLabelNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -285,7 +285,7 @@ func ClearIssueLabels(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -309,7 +309,7 @@ func ClearIssueLabels(ctx *context.APIContext) {
}
func prepareForReplaceOrAdd(ctx *context.APIContext, form api.IssueLabelsOption) (*issues_model.Issue, []*issues_model.Label, error) {
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/issue_pin.go b/routers/api/v1/repo/issue_pin.go
index af3e06332a..0ef9033291 100644
--- a/routers/api/v1/repo/issue_pin.go
+++ b/routers/api/v1/repo/issue_pin.go
@@ -41,7 +41,7 @@ func PinIssue(ctx *context.APIContext) {
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -98,7 +98,7 @@ func UnpinIssue(ctx *context.APIContext) {
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -159,7 +159,7 @@ func MoveIssuePin(ctx *context.APIContext) {
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -169,7 +169,7 @@ func MoveIssuePin(ctx *context.APIContext) {
return
}
- err = issue.MovePin(ctx, int(ctx.ParamsInt64(":position")))
+ err = issue.MovePin(ctx, int(ctx.PathParamInt64(":position")))
if err != nil {
ctx.Error(http.StatusInternalServerError, "MovePin", err)
return
diff --git a/routers/api/v1/repo/issue_reaction.go b/routers/api/v1/repo/issue_reaction.go
index 3ff3d19f13..8d43cd518b 100644
--- a/routers/api/v1/repo/issue_reaction.go
+++ b/routers/api/v1/repo/issue_reaction.go
@@ -51,7 +51,7 @@ func GetIssueCommentReactions(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if issues_model.IsErrCommentNotExist(err) {
ctx.NotFound(err)
@@ -188,7 +188,7 @@ func DeleteIssueCommentReaction(ctx *context.APIContext) {
}
func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOption, isCreateType bool) {
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if issues_model.IsErrCommentNotExist(err) {
ctx.NotFound(err)
@@ -295,7 +295,7 @@ func GetIssueReactions(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -419,7 +419,7 @@ func DeleteIssueReaction(ctx *context.APIContext) {
}
func changeIssueReaction(ctx *context.APIContext, form api.EditReactionOption, isCreateType bool) {
- issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/issue_stopwatch.go b/routers/api/v1/repo/issue_stopwatch.go
index d9054e8f77..4605ae2110 100644
--- a/routers/api/v1/repo/issue_stopwatch.go
+++ b/routers/api/v1/repo/issue_stopwatch.go
@@ -161,7 +161,7 @@ func DeleteIssueStopwatch(ctx *context.APIContext) {
}
func prepareIssueStopwatch(ctx *context.APIContext, shouldExist bool) (*issues_model.Issue, error) {
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/issue_subscription.go b/routers/api/v1/repo/issue_subscription.go
index a535172462..e51baad0b6 100644
--- a/routers/api/v1/repo/issue_subscription.go
+++ b/routers/api/v1/repo/issue_subscription.go
@@ -104,7 +104,7 @@ func DelIssueSubscription(ctx *context.APIContext) {
}
func setIssueSubscription(ctx *context.APIContext, watch bool) {
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -115,7 +115,7 @@ func setIssueSubscription(ctx *context.APIContext, watch bool) {
return
}
- user, err := user_model.GetUserByName(ctx, ctx.Params(":user"))
+ user, err := user_model.GetUserByName(ctx, ctx.PathParam(":user"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound()
@@ -185,7 +185,7 @@ func CheckIssueSubscription(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
@@ -251,7 +251,7 @@ func GetIssueSubscribers(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go
index f83855efac..8d5e9fdad4 100644
--- a/routers/api/v1/repo/issue_tracked_time.go
+++ b/routers/api/v1/repo/issue_tracked_time.go
@@ -75,7 +75,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
ctx.NotFound("Timetracker is disabled")
return
}
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound(err)
@@ -181,7 +181,7 @@ func AddTime(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.AddTimeOption)
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound(err)
@@ -264,7 +264,7 @@ func ResetIssueTime(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound(err)
@@ -337,7 +337,7 @@ func DeleteTime(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound(err)
@@ -356,7 +356,7 @@ func DeleteTime(ctx *context.APIContext) {
return
}
- time, err := issues_model.GetTrackedTimeByID(ctx, ctx.ParamsInt64(":id"))
+ time, err := issues_model.GetTrackedTimeByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if db.IsErrNotExist(err) {
ctx.NotFound(err)
@@ -422,7 +422,7 @@ func ListTrackedTimesByUser(ctx *context.APIContext) {
ctx.Error(http.StatusBadRequest, "", "time tracking disabled")
return
}
- user, err := user_model.GetUserByName(ctx, ctx.Params(":timetrackingusername"))
+ user, err := user_model.GetUserByName(ctx, ctx.PathParam(":timetrackingusername"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound(err)
diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go
index 88444a2625..e5115980eb 100644
--- a/routers/api/v1/repo/key.go
+++ b/routers/api/v1/repo/key.go
@@ -143,7 +143,7 @@ func GetDeployKey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- key, err := asymkey_model.GetDeployKeyByID(ctx, ctx.ParamsInt64(":id"))
+ key, err := asymkey_model.GetDeployKeyByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if asymkey_model.IsErrDeployKeyNotExist(err) {
ctx.NotFound()
@@ -279,7 +279,7 @@ func DeleteDeploykey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := asymkey_service.DeleteDeployKey(ctx, ctx.Doer, ctx.ParamsInt64(":id")); err != nil {
+ if err := asymkey_service.DeleteDeployKey(ctx, ctx.Doer, ctx.PathParamInt64(":id")); err != nil {
if asymkey_model.IsErrKeyAccessDenied(err) {
ctx.Error(http.StatusForbidden, "", "You do not have access to this key")
} else {
diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go
index b6eb51fd20..c2c43db6a4 100644
--- a/routers/api/v1/repo/label.go
+++ b/routers/api/v1/repo/label.go
@@ -99,7 +99,7 @@ func GetLabel(ctx *context.APIContext) {
l *issues_model.Label
err error
)
- strID := ctx.Params(":id")
+ strID := ctx.PathParam(":id")
if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil {
l, err = issues_model.GetLabelInRepoByName(ctx, ctx.Repo.Repository.ID, strID)
} else {
@@ -212,7 +212,7 @@ func EditLabel(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.EditLabelOption)
- l, err := issues_model.GetLabelInRepoByID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
+ l, err := issues_model.GetLabelInRepoByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id"))
if err != nil {
if issues_model.IsErrRepoLabelNotExist(err) {
ctx.NotFound()
@@ -276,7 +276,7 @@ func DeleteLabel(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := issues_model.DeleteLabel(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
+ if err := issues_model.DeleteLabel(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id")); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteLabel", err)
return
}
diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go
index b9534016e4..abe9e4006a 100644
--- a/routers/api/v1/repo/milestone.go
+++ b/routers/api/v1/repo/milestone.go
@@ -282,7 +282,7 @@ func DeleteMilestone(ctx *context.APIContext) {
// getMilestoneByIDOrName get milestone by ID and if not available by name
func getMilestoneByIDOrName(ctx *context.APIContext) *issues_model.Milestone {
- mile := ctx.Params(":id")
+ mile := ctx.PathParam(":id")
mileID, _ := strconv.ParseInt(mile, 0, 64)
if mileID != 0 {
diff --git a/routers/api/v1/repo/mirror.go b/routers/api/v1/repo/mirror.go
index eddd449206..310b82881e 100644
--- a/routers/api/v1/repo/mirror.go
+++ b/routers/api/v1/repo/mirror.go
@@ -224,7 +224,7 @@ func GetPushMirrorByName(ctx *context.APIContext) {
return
}
- mirrorName := ctx.Params(":name")
+ mirrorName := ctx.PathParam(":name")
// Get push mirror of a specific repo by remoteName
pushMirror, exist, err := db.Get[repo_model.PushMirror](ctx, repo_model.PushMirrorOptions{
RepoID: ctx.Repo.Repository.ID,
@@ -325,7 +325,7 @@ func DeletePushMirrorByRemoteName(ctx *context.APIContext) {
return
}
- remoteName := ctx.Params(":name")
+ remoteName := ctx.PathParam(":name")
// Delete push mirror on repo by name.
err := repo_model.DeletePushMirrors(ctx, repo_model.PushMirrorOptions{RepoID: ctx.Repo.Repository.ID, RemoteName: remoteName})
if err != nil {
diff --git a/routers/api/v1/repo/notes.go b/routers/api/v1/repo/notes.go
index a4a1d4eab7..8689d25e15 100644
--- a/routers/api/v1/repo/notes.go
+++ b/routers/api/v1/repo/notes.go
@@ -52,7 +52,7 @@ func GetNote(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- sha := ctx.Params(":sha")
+ sha := ctx.PathParam(":sha")
if !git.IsValidRefPattern(sha) {
ctx.Error(http.StatusUnprocessableEntity, "no valid ref or sha", fmt.Sprintf("no valid ref or sha: %s", sha))
return
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 1fc94708da..ebe876da64 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -187,7 +187,7 @@ func GetPullRequest(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -244,7 +244,7 @@ func GetPullRequestByBaseHead(ctx *context.APIContext) {
var headRepoID int64
var headBranch string
- head := ctx.Params("*")
+ head := ctx.PathParam("*")
if strings.Contains(head, ":") {
split := strings.SplitN(head, ":", 2)
headBranch = split[1]
@@ -272,7 +272,7 @@ func GetPullRequestByBaseHead(ctx *context.APIContext) {
headBranch = head
}
- pr, err := issues_model.GetPullRequestByBaseHeadInfo(ctx, ctx.Repo.Repository.ID, headRepoID, ctx.Params(":base"), headBranch)
+ pr, err := issues_model.GetPullRequestByBaseHeadInfo(ctx, ctx.Repo.Repository.ID, headRepoID, ctx.PathParam(":base"), headBranch)
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -332,7 +332,7 @@ func DownloadPullDiffOrPatch(ctx *context.APIContext) {
// "$ref": "#/responses/string"
// "404":
// "$ref": "#/responses/notFound"
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -342,7 +342,7 @@ func DownloadPullDiffOrPatch(ctx *context.APIContext) {
return
}
var patch bool
- if ctx.Params(":diffType") == "diff" {
+ if ctx.PathParam(":diffType") == "diff" {
patch = false
} else {
patch = true
@@ -590,7 +590,7 @@ func EditPullRequest(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.EditPullRequestOption)
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -804,7 +804,7 @@ func IsPullRequestMerged(ctx *context.APIContext) {
// "404":
// description: pull request has not been merged
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -862,7 +862,7 @@ func MergePullRequest(ctx *context.APIContext) {
form := web.GetForm(ctx).(*forms.MergePullRequestForm)
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":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)
@@ -1221,7 +1221,7 @@ func UpdatePullRequest(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -1320,7 +1320,7 @@ func CancelScheduledAutoMerge(ctx *context.APIContext) {
// "423":
// "$ref": "#/responses/repoArchivedError"
- pullIndex := ctx.ParamsInt64(":index")
+ pullIndex := ctx.PathParamInt64(":index")
pull, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, pullIndex)
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
@@ -1406,7 +1406,7 @@ func GetPullRequestCommits(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -1529,7 +1529,7 @@ func GetPullRequestFiles(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/pull_review.go b/routers/api/v1/repo/pull_review.go
index 4b481790fb..c2e4966498 100644
--- a/routers/api/v1/repo/pull_review.go
+++ b/routers/api/v1/repo/pull_review.go
@@ -61,7 +61,7 @@ func ListPullReviews(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":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)
@@ -307,7 +307,7 @@ func CreatePullReview(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
opts := web.GetForm(ctx).(*api.CreatePullReviewOptions)
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":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)
@@ -534,7 +534,7 @@ func preparePullReviewType(ctx *context.APIContext, pr *issues_model.PullRequest
// prepareSingleReview return review, related pull and false or nil, nil and true if an error happen
func prepareSingleReview(ctx *context.APIContext) (*issues_model.Review, *issues_model.PullRequest, bool) {
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":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)
@@ -544,7 +544,7 @@ func prepareSingleReview(ctx *context.APIContext) (*issues_model.Review, *issues
return nil, nil, true
}
- review, err := issues_model.GetReviewByID(ctx, ctx.ParamsInt64(":id"))
+ review, err := issues_model.GetReviewByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if issues_model.IsErrReviewNotExist(err) {
ctx.NotFound("GetReviewByID", err)
@@ -658,7 +658,7 @@ func DeleteReviewRequests(ctx *context.APIContext) {
}
func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions, isAdd bool) {
- pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":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/api/v1/repo/release.go b/routers/api/v1/repo/release.go
index f92fb86f5c..ef587f6274 100644
--- a/routers/api/v1/repo/release.go
+++ b/routers/api/v1/repo/release.go
@@ -50,7 +50,7 @@ func GetRelease(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- id := ctx.ParamsInt64(":id")
+ id := ctx.PathParamInt64(":id")
release, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, id)
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
ctx.Error(http.StatusInternalServerError, "GetReleaseForRepoByID", err)
@@ -317,7 +317,7 @@ func EditRelease(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.EditReleaseOption)
- id := ctx.ParamsInt64(":id")
+ id := ctx.PathParamInt64(":id")
rel, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, id)
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
ctx.Error(http.StatusInternalServerError, "GetReleaseForRepoByID", err)
@@ -394,7 +394,7 @@ func DeleteRelease(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
- id := ctx.ParamsInt64(":id")
+ id := ctx.PathParamInt64(":id")
rel, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, id)
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
ctx.Error(http.StatusInternalServerError, "GetReleaseForRepoByID", err)
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go
index 59fd83e3a2..4a2371e012 100644
--- a/routers/api/v1/repo/release_attachment.go
+++ b/routers/api/v1/repo/release_attachment.go
@@ -72,12 +72,12 @@ func GetReleaseAttachment(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- releaseID := ctx.ParamsInt64(":id")
+ releaseID := ctx.PathParamInt64(":id")
if !checkReleaseMatchRepo(ctx, releaseID) {
return
}
- attachID := ctx.ParamsInt64(":attachment_id")
+ attachID := ctx.PathParamInt64(":attachment_id")
attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
@@ -126,7 +126,7 @@ func ListReleaseAttachments(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- releaseID := ctx.ParamsInt64(":id")
+ releaseID := ctx.PathParamInt64(":id")
release, err := repo_model.GetReleaseByID(ctx, releaseID)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
@@ -199,7 +199,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
}
// Check if release exists an load release
- releaseID := ctx.ParamsInt64(":id")
+ releaseID := ctx.PathParamInt64(":id")
if !checkReleaseMatchRepo(ctx, releaseID) {
return
}
@@ -297,12 +297,12 @@ func EditReleaseAttachment(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.EditAttachmentOptions)
// Check if release exists an load release
- releaseID := ctx.ParamsInt64(":id")
+ releaseID := ctx.PathParamInt64(":id")
if !checkReleaseMatchRepo(ctx, releaseID) {
return
}
- attachID := ctx.ParamsInt64(":attachment_id")
+ attachID := ctx.PathParamInt64(":attachment_id")
attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
@@ -365,12 +365,12 @@ func DeleteReleaseAttachment(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
// Check if release exists an load release
- releaseID := ctx.ParamsInt64(":id")
+ releaseID := ctx.PathParamInt64(":id")
if !checkReleaseMatchRepo(ctx, releaseID) {
return
}
- attachID := ctx.ParamsInt64(":attachment_id")
+ attachID := ctx.PathParamInt64(":attachment_id")
attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
diff --git a/routers/api/v1/repo/release_tags.go b/routers/api/v1/repo/release_tags.go
index f845fad53b..6df47af8d9 100644
--- a/routers/api/v1/repo/release_tags.go
+++ b/routers/api/v1/repo/release_tags.go
@@ -42,7 +42,7 @@ func GetReleaseByTag(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- tag := ctx.Params(":tag")
+ tag := ctx.PathParam(":tag")
release, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tag)
if err != nil {
@@ -95,7 +95,7 @@ func DeleteReleaseByTag(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
- tag := ctx.Params(":tag")
+ tag := ctx.PathParam(":tag")
release, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tag)
if err != nil {
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 4f617d27af..1bcec8fcf7 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -491,7 +491,7 @@ func CreateOrgRepo(ctx *context.APIContext) {
// "403":
// "$ref": "#/responses/forbidden"
opt := web.GetForm(ctx).(*api.CreateRepoOption)
- org, err := organization.GetOrgByName(ctx, ctx.Params(":org"))
+ org, err := organization.GetOrgByName(ctx, ctx.PathParam(":org"))
if err != nil {
if organization.IsErrOrgNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -571,7 +571,7 @@ func GetByID(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- repo, err := repo_model.GetRepositoryByID(ctx, ctx.ParamsInt64(":id"))
+ repo, err := repo_model.GetRepositoryByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if repo_model.IsErrRepoNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index 9e36ea0aed..8c910a68f9 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -53,7 +53,7 @@ func NewCommitStatus(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.CreateStatusOption)
- sha := ctx.Params("sha")
+ sha := ctx.PathParam("sha")
if len(sha) == 0 {
ctx.Error(http.StatusBadRequest, "sha not given", nil)
return
@@ -123,7 +123,7 @@ func GetCommitStatuses(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- getCommitStatuses(ctx, ctx.Params("sha"))
+ getCommitStatuses(ctx, ctx.PathParam("sha"))
}
// GetCommitStatusesByRef returns all statuses for any given commit ref
@@ -177,7 +177,7 @@ func GetCommitStatusesByRef(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- filter := utils.ResolveRefOrSha(ctx, ctx.Params("ref"))
+ filter := utils.ResolveRefOrSha(ctx, ctx.PathParam("ref"))
if ctx.Written() {
return
}
@@ -257,7 +257,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- sha := utils.ResolveRefOrSha(ctx, ctx.Params("ref"))
+ sha := utils.ResolveRefOrSha(ctx, ctx.PathParam("ref"))
if ctx.Written() {
return
}
diff --git a/routers/api/v1/repo/tag.go b/routers/api/v1/repo/tag.go
index f72034950f..a72df78666 100644
--- a/routers/api/v1/repo/tag.go
+++ b/routers/api/v1/repo/tag.go
@@ -102,7 +102,7 @@ func GetAnnotatedTag(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- sha := ctx.Params("sha")
+ sha := ctx.PathParam("sha")
if len(sha) == 0 {
ctx.Error(http.StatusBadRequest, "", "SHA not provided")
return
@@ -147,7 +147,7 @@ func GetTag(ctx *context.APIContext) {
// "$ref": "#/responses/Tag"
// "404":
// "$ref": "#/responses/notFound"
- tagName := ctx.Params("*")
+ tagName := ctx.PathParam("*")
tag, err := ctx.Repo.GitRepo.GetTag(tagName)
if err != nil {
@@ -263,7 +263,7 @@ func DeleteTag(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
// "423":
// "$ref": "#/responses/repoArchivedError"
- tagName := ctx.Params("*")
+ tagName := ctx.PathParam("*")
tag, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
if err != nil {
@@ -358,7 +358,7 @@ func GetTagProtection(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
repo := ctx.Repo.Repository
- id := ctx.ParamsInt64(":id")
+ id := ctx.PathParamInt64(":id")
pt, err := git_model.GetProtectedTagByID(ctx, id)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedTagByID", err)
@@ -522,7 +522,7 @@ func EditTagProtection(ctx *context.APIContext) {
repo := ctx.Repo.Repository
form := web.GetForm(ctx).(*api.EditTagProtectionOption)
- id := ctx.ParamsInt64(":id")
+ id := ctx.PathParamInt64(":id")
pt, err := git_model.GetProtectedTagByID(ctx, id)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedTagByID", err)
@@ -617,7 +617,7 @@ func DeleteTagProtection(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
repo := ctx.Repo.Repository
- id := ctx.ParamsInt64(":id")
+ id := ctx.PathParamInt64(":id")
pt, err := git_model.GetProtectedTagByID(ctx, id)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedTagByID", err)
diff --git a/routers/api/v1/repo/teams.go b/routers/api/v1/repo/teams.go
index 0ecf3a39d8..ddd325482d 100644
--- a/routers/api/v1/repo/teams.go
+++ b/routers/api/v1/repo/teams.go
@@ -222,7 +222,7 @@ func changeRepoTeam(ctx *context.APIContext, add bool) {
}
func getTeamByParam(ctx *context.APIContext) *organization.Team {
- team, err := organization.GetTeam(ctx, ctx.Repo.Owner.ID, ctx.Params(":team"))
+ team, err := organization.GetTeam(ctx, ctx.Repo.Owner.ID, ctx.PathParam(":team"))
if err != nil {
if organization.IsErrTeamNotExist(err) {
ctx.Error(http.StatusNotFound, "TeamNotExit", err)
diff --git a/routers/api/v1/repo/topic.go b/routers/api/v1/repo/topic.go
index 9852caa989..6b9eedf6e0 100644
--- a/routers/api/v1/repo/topic.go
+++ b/routers/api/v1/repo/topic.go
@@ -162,7 +162,7 @@ func AddTopic(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/invalidTopicsError"
- topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic")))
+ topicName := strings.TrimSpace(strings.ToLower(ctx.PathParam(":topic")))
if !repo_model.ValidateTopic(topicName) {
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
@@ -229,7 +229,7 @@ func DeleteTopic(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/invalidTopicsError"
- topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic")))
+ topicName := strings.TrimSpace(strings.ToLower(ctx.PathParam(":topic")))
if !repo_model.ValidateTopic(topicName) {
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
diff --git a/routers/api/v1/repo/tree.go b/routers/api/v1/repo/tree.go
index 353a996d5b..efb247c19e 100644
--- a/routers/api/v1/repo/tree.go
+++ b/routers/api/v1/repo/tree.go
@@ -56,7 +56,7 @@ func GetTree(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- sha := ctx.Params(":sha")
+ sha := ctx.PathParam(":sha")
if len(sha) == 0 {
ctx.Error(http.StatusBadRequest, "", "sha not provided")
return
diff --git a/routers/api/v1/shared/block.go b/routers/api/v1/shared/block.go
index a1e65625ed..490a48f81c 100644
--- a/routers/api/v1/shared/block.go
+++ b/routers/api/v1/shared/block.go
@@ -40,7 +40,7 @@ func ListBlocks(ctx *context.APIContext, blocker *user_model.User) {
}
func CheckUserBlock(ctx *context.APIContext, blocker *user_model.User) {
- blockee, err := user_model.GetUserByName(ctx, ctx.Params("username"))
+ blockee, err := user_model.GetUserByName(ctx, ctx.PathParam("username"))
if err != nil {
ctx.NotFound("GetUserByName", err)
return
@@ -60,7 +60,7 @@ func CheckUserBlock(ctx *context.APIContext, blocker *user_model.User) {
}
func BlockUser(ctx *context.APIContext, blocker *user_model.User) {
- blockee, err := user_model.GetUserByName(ctx, ctx.Params("username"))
+ blockee, err := user_model.GetUserByName(ctx, ctx.PathParam("username"))
if err != nil {
ctx.NotFound("GetUserByName", err)
return
@@ -79,7 +79,7 @@ func BlockUser(ctx *context.APIContext, blocker *user_model.User) {
}
func UnblockUser(ctx *context.APIContext, doer, blocker *user_model.User) {
- blockee, err := user_model.GetUserByName(ctx, ctx.Params("username"))
+ blockee, err := user_model.GetUserByName(ctx, ctx.PathParam("username"))
if err != nil {
ctx.NotFound("GetUserByName", err)
return
diff --git a/routers/api/v1/user/action.go b/routers/api/v1/user/action.go
index bf78c2c864..22707196f4 100644
--- a/routers/api/v1/user/action.go
+++ b/routers/api/v1/user/action.go
@@ -49,7 +49,7 @@ func CreateOrUpdateSecret(ctx *context.APIContext) {
opt := web.GetForm(ctx).(*api.CreateOrUpdateSecretOption)
- _, created, err := secret_service.CreateOrUpdateSecret(ctx, ctx.Doer.ID, 0, ctx.Params("secretname"), opt.Data)
+ _, created, err := secret_service.CreateOrUpdateSecret(ctx, ctx.Doer.ID, 0, ctx.PathParam("secretname"), opt.Data)
if err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "CreateOrUpdateSecret", err)
@@ -91,7 +91,7 @@ func DeleteSecret(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- err := secret_service.DeleteSecretByName(ctx, ctx.Doer.ID, 0, ctx.Params("secretname"))
+ err := secret_service.DeleteSecretByName(ctx, ctx.Doer.ID, 0, ctx.PathParam("secretname"))
if err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "DeleteSecret", err)
@@ -138,7 +138,7 @@ func CreateVariable(ctx *context.APIContext) {
opt := web.GetForm(ctx).(*api.CreateVariableOption)
ownerID := ctx.Doer.ID
- variableName := ctx.Params("variablename")
+ variableName := ctx.PathParam("variablename")
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
OwnerID: ownerID,
@@ -198,7 +198,7 @@ func UpdateVariable(ctx *context.APIContext) {
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
OwnerID: ctx.Doer.ID,
- Name: ctx.Params("variablename"),
+ Name: ctx.PathParam("variablename"),
})
if err != nil {
if errors.Is(err, util.ErrNotExist) {
@@ -210,7 +210,7 @@ func UpdateVariable(ctx *context.APIContext) {
}
if opt.Name == "" {
- opt.Name = ctx.Params("variablename")
+ opt.Name = ctx.PathParam("variablename")
}
if _, err := actions_service.UpdateVariable(ctx, v.ID, opt.Name, opt.Value); err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
@@ -247,7 +247,7 @@ func DeleteVariable(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := actions_service.DeleteVariableByName(ctx, ctx.Doer.ID, 0, ctx.Params("variablename")); err != nil {
+ if err := actions_service.DeleteVariableByName(ctx, ctx.Doer.ID, 0, ctx.PathParam("variablename")); err != nil {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.Error(http.StatusBadRequest, "DeleteVariableByName", err)
} else if errors.Is(err, util.ErrNotExist) {
@@ -284,7 +284,7 @@ func GetVariable(ctx *context.APIContext) {
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
OwnerID: ctx.Doer.ID,
- Name: ctx.Params("variablename"),
+ Name: ctx.PathParam("variablename"),
})
if err != nil {
if errors.Is(err, util.ErrNotExist) {
diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go
index 88e314ed31..60354b1f26 100644
--- a/routers/api/v1/user/app.go
+++ b/routers/api/v1/user/app.go
@@ -160,7 +160,7 @@ func DeleteAccessToken(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/error"
- token := ctx.Params(":id")
+ token := ctx.PathParam(":id")
tokenID, _ := strconv.ParseInt(token, 0, 64)
if tokenID == 0 {
@@ -300,7 +300,7 @@ func DeleteOauth2Application(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
- appID := ctx.ParamsInt64(":id")
+ appID := ctx.PathParamInt64(":id")
if err := auth_model.DeleteOAuth2Application(ctx, appID, ctx.Doer.ID); err != nil {
if auth_model.IsErrOAuthApplicationNotFound(err) {
ctx.NotFound()
@@ -332,7 +332,7 @@ func GetOauth2Application(ctx *context.APIContext) {
// "$ref": "#/responses/OAuth2Application"
// "404":
// "$ref": "#/responses/notFound"
- appID := ctx.ParamsInt64(":id")
+ appID := ctx.PathParamInt64(":id")
app, err := auth_model.GetOAuth2ApplicationByID(ctx, appID)
if err != nil {
if auth_model.IsErrOauthClientIDInvalid(err) || auth_model.IsErrOAuthApplicationNotFound(err) {
@@ -376,7 +376,7 @@ func UpdateOauth2Application(ctx *context.APIContext) {
// "$ref": "#/responses/OAuth2Application"
// "404":
// "$ref": "#/responses/notFound"
- appID := ctx.ParamsInt64(":id")
+ appID := ctx.PathParamInt64(":id")
data := web.GetForm(ctx).(*api.CreateOAuth2ApplicationOptions)
diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go
index 5a2f995e1b..ba5c0fdc45 100644
--- a/routers/api/v1/user/gpg_key.go
+++ b/routers/api/v1/user/gpg_key.go
@@ -116,7 +116,7 @@ func GetGPGKey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- key, err := asymkey_model.GetGPGKeyForUserByID(ctx, ctx.Doer.ID, ctx.ParamsInt64(":id"))
+ key, err := asymkey_model.GetGPGKeyForUserByID(ctx, ctx.Doer.ID, ctx.PathParamInt64(":id"))
if err != nil {
if asymkey_model.IsErrGPGKeyNotExist(err) {
ctx.NotFound()
@@ -280,7 +280,7 @@ func DeleteGPGKey(ctx *context.APIContext) {
return
}
- if err := asymkey_model.DeleteGPGKey(ctx, ctx.Doer, ctx.ParamsInt64(":id")); err != nil {
+ if err := asymkey_model.DeleteGPGKey(ctx, ctx.Doer, ctx.PathParamInt64(":id")); err != nil {
if asymkey_model.IsErrGPGKeyAccessDenied(err) {
ctx.Error(http.StatusForbidden, "", "You do not have access to this key")
} else {
diff --git a/routers/api/v1/user/helper.go b/routers/api/v1/user/helper.go
index 8b5c64e291..23a526cd67 100644
--- a/routers/api/v1/user/helper.go
+++ b/routers/api/v1/user/helper.go
@@ -12,7 +12,7 @@ import (
// GetUserByParamsName get user by name
func GetUserByParamsName(ctx *context.APIContext, name string) *user_model.User {
- username := ctx.Params(name)
+ username := ctx.PathParam(name)
user, err := user_model.GetUserByName(ctx, username)
if err != nil {
if user_model.IsErrUserNotExist(err) {
diff --git a/routers/api/v1/user/hook.go b/routers/api/v1/user/hook.go
index 9d9ca5bf01..b4605c8a29 100644
--- a/routers/api/v1/user/hook.go
+++ b/routers/api/v1/user/hook.go
@@ -57,7 +57,7 @@ func GetHook(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/Hook"
- hook, err := utils.GetOwnerHook(ctx, ctx.Doer.ID, ctx.ParamsInt64("id"))
+ hook, err := utils.GetOwnerHook(ctx, ctx.Doer.ID, ctx.PathParamInt64("id"))
if err != nil {
return
}
@@ -129,7 +129,7 @@ func EditHook(ctx *context.APIContext) {
ctx,
ctx.Doer,
web.GetForm(ctx).(*api.EditHookOption),
- ctx.ParamsInt64("id"),
+ ctx.PathParamInt64("id"),
)
}
@@ -154,6 +154,6 @@ func DeleteHook(ctx *context.APIContext) {
utils.DeleteOwnerHook(
ctx,
ctx.Doer,
- ctx.ParamsInt64("id"),
+ ctx.PathParamInt64("id"),
)
}
diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go
index d9456e7ec6..e4278c2ec0 100644
--- a/routers/api/v1/user/key.go
+++ b/routers/api/v1/user/key.go
@@ -55,7 +55,7 @@ func listPublicKeys(ctx *context.APIContext, user *user_model.User) {
var count int
fingerprint := ctx.FormString("fingerprint")
- username := ctx.Params("username")
+ username := ctx.PathParam("username")
if fingerprint != "" {
var userID int64 // Unrestricted
@@ -179,7 +179,7 @@ func GetPublicKey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- key, err := asymkey_model.GetPublicKeyByID(ctx, ctx.ParamsInt64(":id"))
+ key, err := asymkey_model.GetPublicKeyByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if asymkey_model.IsErrKeyNotExist(err) {
ctx.NotFound()
@@ -274,7 +274,7 @@ func DeletePublicKey(ctx *context.APIContext) {
return
}
- id := ctx.ParamsInt64(":id")
+ id := ctx.PathParamInt64(":id")
externallyManaged, err := asymkey_model.PublicKeyIsExternallyManaged(ctx, id)
if err != nil {
if asymkey_model.IsErrKeyNotExist(err) {
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go
index 09147cd2ae..fedad87fc4 100644
--- a/routers/api/v1/user/user.go
+++ b/routers/api/v1/user/user.go
@@ -113,7 +113,7 @@ func GetInfo(ctx *context.APIContext) {
if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
// fake ErrUserNotExist error message to not leak information about existence
- ctx.NotFound("GetUserByName", user_model.ErrUserNotExist{Name: ctx.Params(":username")})
+ ctx.NotFound("GetUserByName", user_model.ErrUserNotExist{Name: ctx.PathParam(":username")})
return
}
ctx.JSON(http.StatusOK, convert.ToUser(ctx, ctx.ContextUser, ctx.Doer))
diff --git a/routers/init.go b/routers/init.go
index 5cf40a4151..e21f763c1e 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -177,9 +177,9 @@ func InitWebInstalled(ctx context.Context) {
}
// NormalRoutes represents non install routes
-func NormalRoutes() *web.Route {
+func NormalRoutes() *web.Router {
_ = templates.HTMLRenderer()
- r := web.NewRoute()
+ r := web.NewRouter()
r.Use(common.ProtocolMiddlewares()...)
r.Mount("/", web_routers.Routes())
diff --git a/routers/install/routes.go b/routers/install/routes.go
index 06c9d389a6..7309a405d4 100644
--- a/routers/install/routes.go
+++ b/routers/install/routes.go
@@ -17,12 +17,12 @@ import (
)
// Routes registers the installation routes
-func Routes() *web.Route {
- base := web.NewRoute()
+func Routes() *web.Router {
+ base := web.NewRouter()
base.Use(common.ProtocolMiddlewares()...)
base.Methods("GET, HEAD", "/assets/*", public.FileHandlerFunc())
- r := web.NewRoute()
+ r := web.NewRouter()
r.Use(common.Sessioner(), Contexter())
r.Get("/", Install) // it must be on the root, because the "install.js" use the window.location to replace the "localhost" AppURL
r.Post("/", web.Bind(forms.InstallForm{}), SubmitInstall)
diff --git a/routers/private/default_branch.go b/routers/private/default_branch.go
index 33890be6a9..7be909f955 100644
--- a/routers/private/default_branch.go
+++ b/routers/private/default_branch.go
@@ -16,9 +16,9 @@ import (
// SetDefaultBranch updates the default branch
func SetDefaultBranch(ctx *gitea_context.PrivateContext) {
- ownerName := ctx.Params(":owner")
- repoName := ctx.Params(":repo")
- branch := ctx.Params(":branch")
+ ownerName := ctx.PathParam(":owner")
+ repoName := ctx.PathParam(":repo")
+ branch := ctx.PathParam(":branch")
ctx.Repo.Repository.DefaultBranch = branch
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.Repository.DefaultBranch); err != nil {
diff --git a/routers/private/hook_post_receive.go b/routers/private/hook_post_receive.go
index 0c2c1836ed..2d1688523c 100644
--- a/routers/private/hook_post_receive.go
+++ b/routers/private/hook_post_receive.go
@@ -40,8 +40,8 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
// b) our update function will likely change the repository in the db so we will need to refresh it
// c) we don't always need the repo
- ownerName := ctx.Params(":owner")
- repoName := ctx.Params(":repo")
+ ownerName := ctx.PathParam(":owner")
+ repoName := ctx.PathParam(":repo")
// defer getting the repository at this point - as we should only retrieve it if we're going to call update
var (
diff --git a/routers/private/internal.go b/routers/private/internal.go
index ede310113c..61e604b7a9 100644
--- a/routers/private/internal.go
+++ b/routers/private/internal.go
@@ -48,8 +48,8 @@ func bind[T any](_ T) any {
// Routes registers all internal APIs routes to web application.
// These APIs will be invoked by internal commands for example `gitea serv` and etc.
-func Routes() *web.Route {
- r := web.NewRoute()
+func Routes() *web.Router {
+ r := web.NewRouter()
r.Use(context.PrivateContexter())
r.Use(CheckInternalToken)
// Log the real ip address of the request from SSH is really helpful for diagnosing sometimes.
diff --git a/routers/private/internal_repo.go b/routers/private/internal_repo.go
index e8ee8ba8ac..aad0a3fb1a 100644
--- a/routers/private/internal_repo.go
+++ b/routers/private/internal_repo.go
@@ -19,8 +19,8 @@ import (
// RepoAssignment assigns the repository and gitrepository to the private context
func RepoAssignment(ctx *gitea_context.PrivateContext) context.CancelFunc {
- ownerName := ctx.Params(":owner")
- repoName := ctx.Params(":repo")
+ ownerName := ctx.PathParam(":owner")
+ repoName := ctx.PathParam(":repo")
repo := loadRepository(ctx, ownerName, repoName)
if ctx.Written() {
diff --git a/routers/private/key.go b/routers/private/key.go
index 5b8f238a83..063db76520 100644
--- a/routers/private/key.go
+++ b/routers/private/key.go
@@ -14,8 +14,8 @@ import (
// UpdatePublicKeyInRepo update public key and deploy key updates
func UpdatePublicKeyInRepo(ctx *context.PrivateContext) {
- keyID := ctx.ParamsInt64(":id")
- repoID := ctx.ParamsInt64(":repoid")
+ keyID := ctx.PathParamInt64(":id")
+ repoID := ctx.PathParamInt64(":repoid")
if err := asymkey_model.UpdatePublicKeyUpdated(ctx, keyID); err != nil {
ctx.JSON(http.StatusInternalServerError, private.Response{
Err: err.Error(),
diff --git a/routers/private/manager.go b/routers/private/manager.go
index a6aa03e4ec..c712bbcf21 100644
--- a/routers/private/manager.go
+++ b/routers/private/manager.go
@@ -88,8 +88,8 @@ func SetLogSQL(ctx *context.PrivateContext) {
// RemoveLogger removes a logger
func RemoveLogger(ctx *context.PrivateContext) {
- logger := ctx.Params("logger")
- writer := ctx.Params("writer")
+ logger := ctx.PathParam("logger")
+ writer := ctx.PathParam("writer")
err := log.GetManager().GetLogger(logger).RemoveWriter(writer)
if err != nil {
ctx.JSON(http.StatusInternalServerError, private.Response{
diff --git a/routers/private/serv.go b/routers/private/serv.go
index 1c309865d7..dbb28cc2bb 100644
--- a/routers/private/serv.go
+++ b/routers/private/serv.go
@@ -25,7 +25,7 @@ import (
// ServNoCommand returns information about the provided keyid
func ServNoCommand(ctx *context.PrivateContext) {
- keyID := ctx.ParamsInt64(":keyid")
+ keyID := ctx.PathParamInt64(":keyid")
if keyID <= 0 {
ctx.JSON(http.StatusBadRequest, private.Response{
UserMsg: fmt.Sprintf("Bad key id: %d", keyID),
@@ -77,9 +77,9 @@ func ServNoCommand(ctx *context.PrivateContext) {
// ServCommand returns information about the provided keyid
func ServCommand(ctx *context.PrivateContext) {
- keyID := ctx.ParamsInt64(":keyid")
- ownerName := ctx.Params(":owner")
- repoName := ctx.Params(":repo")
+ keyID := ctx.PathParamInt64(":keyid")
+ ownerName := ctx.PathParam(":owner")
+ repoName := ctx.PathParam(":repo")
mode := perm.AccessMode(ctx.FormInt("mode"))
// Set the basic parts of the results to return
diff --git a/routers/web/admin/auths.go b/routers/web/admin/auths.go
index ba487d1045..3b89be0f8f 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.ParamsInt64(":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.ParamsInt64(":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.ParamsInt64(":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.Params(":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/queue.go b/routers/web/admin/queue.go
index d8c50730b1..dce8f8077f 100644
--- a/routers/web/admin/queue.go
+++ b/routers/web/admin/queue.go
@@ -24,7 +24,7 @@ func Queues(ctx *context.Context) {
// QueueManage shows details for a specific queue
func QueueManage(ctx *context.Context) {
- qid := ctx.ParamsInt64("qid")
+ qid := ctx.PathParamInt64("qid")
mq := queue.GetManager().GetManagedQueue(qid)
if mq == nil {
ctx.Status(http.StatusNotFound)
@@ -38,7 +38,7 @@ func QueueManage(ctx *context.Context) {
// QueueSet sets the maximum number of workers and other settings for this queue
func QueueSet(ctx *context.Context) {
- qid := ctx.ParamsInt64("qid")
+ qid := ctx.PathParamInt64("qid")
mq := queue.GetManager().GetManagedQueue(qid)
if mq == nil {
ctx.Status(http.StatusNotFound)
@@ -72,7 +72,7 @@ func QueueRemoveAllItems(ctx *context.Context) {
// Gitea's queue doesn't have transaction support
// So in rare cases, the queue could be corrupted/out-of-sync
// Site admin could remove all items from the queue to make it work again
- qid := ctx.ParamsInt64("qid")
+ qid := ctx.PathParamInt64("qid")
mq := queue.GetManager().GetManagedQueue(qid)
if mq == nil {
ctx.Status(http.StatusNotFound)
diff --git a/routers/web/admin/stacktrace.go b/routers/web/admin/stacktrace.go
index d6def94bb4..b3b635af5b 100644
--- a/routers/web/admin/stacktrace.go
+++ b/routers/web/admin/stacktrace.go
@@ -40,7 +40,7 @@ func Stacktrace(ctx *context.Context) {
// StacktraceCancel cancels a process
func StacktraceCancel(ctx *context.Context) {
- pid := ctx.Params("pid")
+ pid := ctx.PathParam("pid")
process.GetManager().Cancel(process.IDType(pid))
ctx.JSONRedirect(setting.AppSubURL + "/admin/monitor/stacktrace")
}
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index d2330d5fa1..623b39b4ef 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.ParamsInt64(":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.Params(":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.ParamsInt64(":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.Params(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
return
}
@@ -503,16 +503,16 @@ func DeleteUser(ctx *context.Context) {
switch {
case models.IsErrUserOwnRepos(err):
ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo"))
- ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
case models.IsErrUserHasOrgs(err):
ctx.Flash.Error(ctx.Tr("admin.users.still_has_org"))
- ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
case models.IsErrUserOwnPackages(err):
ctx.Flash.Error(ctx.Tr("admin.users.still_own_packages"))
- ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
case models.IsErrDeleteLastAdminUser(err):
ctx.Flash.Error(ctx.Tr("auth.last_admin"))
- ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid")))
+ ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid")))
default:
ctx.ServerError("DeleteUser", err)
}
diff --git a/routers/web/auth/auth_test.go b/routers/web/auth/auth_test.go
index 45525a5c6f..cbcb2a5222 100644
--- a/routers/web/auth/auth_test.go
+++ b/routers/web/auth/auth_test.go
@@ -71,7 +71,7 @@ func TestSignUpOAuth2ButMissingFields(t *testing.T) {
mockOpt := contexttest.MockContextOption{SessionStore: session.NewMockStore("dummy-sid")}
ctx, resp := contexttest.MockContext(t, "/user/oauth2/dummy-auth-source/callback?code=dummy-code", mockOpt)
- ctx.SetParams("provider", "dummy-auth-source")
+ ctx.SetPathParam("provider", "dummy-auth-source")
SignInOAuthCallback(ctx)
assert.Equal(t, http.StatusSeeOther, resp.Code)
assert.Equal(t, "/user/link_account", test.RedirectURL(resp))
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index b337b6b156..50f0dff2b6 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -865,7 +865,7 @@ func handleAuthorizeError(ctx *context.Context, authErr AuthorizeError, redirect
// SignInOAuth handles the OAuth2 login buttons
func SignInOAuth(ctx *context.Context) {
- provider := ctx.Params(":provider")
+ provider := ctx.PathParam(":provider")
authSource, err := auth.GetActiveOAuth2SourceByName(ctx, provider)
if err != nil {
@@ -904,7 +904,7 @@ func SignInOAuth(ctx *context.Context) {
// SignInOAuthCallback handles the callback from the given provider
func SignInOAuthCallback(ctx *context.Context) {
- provider := ctx.Params(":provider")
+ provider := ctx.PathParam(":provider")
if ctx.Req.FormValue("error") != "" {
var errorKeyValues []string
diff --git a/routers/web/devtest/devtest.go b/routers/web/devtest/devtest.go
index dd20663f94..8c343197d9 100644
--- a/routers/web/devtest/devtest.go
+++ b/routers/web/devtest/devtest.go
@@ -62,5 +62,5 @@ func Tmpl(ctx *context.Context) {
time.Sleep(2 * time.Second)
}
- ctx.HTML(http.StatusOK, base.TplName("devtest"+path.Clean("/"+ctx.Params("sub"))))
+ ctx.HTML(http.StatusOK, base.TplName("devtest"+path.Clean("/"+ctx.PathParam("sub"))))
}
diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go
index 1d17f962f2..67f138aca9 100644
--- a/routers/web/explore/repo.go
+++ b/routers/web/explore/repo.go
@@ -37,8 +37,8 @@ type RepoSearchOptions struct {
// This function is also used to render the Admin Repository Management page.
func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
// Sitemap index for sitemap paths
- page := int(ctx.ParamsInt64("idx"))
- isSitemap := ctx.Params("idx") != ""
+ page := int(ctx.PathParamInt64("idx"))
+ isSitemap := ctx.PathParam("idx") != ""
if page <= 1 {
page = ctx.FormInt("page")
}
diff --git a/routers/web/explore/user.go b/routers/web/explore/user.go
index b79a79fb2c..18337aff48 100644
--- a/routers/web/explore/user.go
+++ b/routers/web/explore/user.go
@@ -33,8 +33,8 @@ func isKeywordValid(keyword string) bool {
// RenderUserSearch render user search page
func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions, tplName base.TplName) {
// Sitemap index for sitemap paths
- opts.Page = int(ctx.ParamsInt64("idx"))
- isSitemap := ctx.Params("idx") != ""
+ opts.Page = int(ctx.PathParamInt64("idx"))
+ isSitemap := ctx.PathParam("idx") != ""
if opts.Page <= 1 {
opts.Page = ctx.FormInt("page")
}
diff --git a/routers/web/feed/render.go b/routers/web/feed/render.go
index a41808c24a..f975fc7cb2 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.Params(":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/githttp.go b/routers/web/githttp.go
index 5f1dedce76..102c92e120 100644
--- a/routers/web/githttp.go
+++ b/routers/web/githttp.go
@@ -25,7 +25,7 @@ func requireSignIn(ctx *context.Context) {
}
}
-func gitHTTPRouters(m *web.Route) {
+func gitHTTPRouters(m *web.Router) {
m.Group("", func() {
m.Methods("POST,OPTIONS", "/git-upload-pack", repo.ServiceUploadPack)
m.Methods("POST,OPTIONS", "/git-receive-pack", repo.ServiceReceivePack)
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index 846b1de18a..c3fc4e099a 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.Params(":username")
+ uname := ctx.PathParam(":username")
if strings.HasSuffix(uname, ".keys") || strings.HasSuffix(uname, ".gpg") {
ctx.NotFound("", nil)
return
}
- ctx.SetParams(":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 63ac57cf0d..58d0b9b8c4 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.Params(":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.Params(":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.Params(":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 9ab3c21cb2..eea539f6d9 100644
--- a/routers/web/org/projects.go
+++ b/routers/web/org/projects.go
@@ -194,7 +194,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.Params(":action") {
+ switch ctx.PathParam(":action") {
case "open":
toClose = false
case "close":
@@ -203,7 +203,7 @@ func ChangeProjectStatus(ctx *context.Context) {
ctx.JSONRedirect(ctx.ContextUser.HomeLink() + "/-/projects")
return
}
- id := ctx.ParamsInt64(":id")
+ id := ctx.PathParamInt64(":id")
if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, 0, id, toClose); err != nil {
ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err)
@@ -214,7 +214,7 @@ func ChangeProjectStatus(ctx *context.Context) {
// DeleteProject delete a project
func DeleteProject(ctx *context.Context) {
- p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -243,7 +243,7 @@ func RenderEditProject(ctx *context.Context) {
shared_user.RenderUserHeader(ctx)
- p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -267,7 +267,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.ParamsInt64(":id")
+ projectID := ctx.PathParamInt64(":id")
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
ctx.Data["PageIsEditProjects"] = true
ctx.Data["PageIsViewProjects"] = true
@@ -316,7 +316,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.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -398,18 +398,18 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":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.ParamsInt64(":columnID"))
+ pb, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
if err != nil {
ctx.ServerError("GetProjectColumn", err)
return
}
- if pb.ProjectID != ctx.ParamsInt64(":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),
})
@@ -423,7 +423,7 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- if err := project_model.DeleteColumnByID(ctx, ctx.ParamsInt64(":columnID")); err != nil {
+ if err := project_model.DeleteColumnByID(ctx, ctx.PathParamInt64(":columnID")); err != nil {
ctx.ServerError("DeleteProjectColumnByID", err)
return
}
@@ -435,7 +435,7 @@ func DeleteProjectColumn(ctx *context.Context) {
func AddColumnToProjectPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditProjectColumnForm)
- project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -463,18 +463,18 @@ func CheckProjectColumnChangePermissions(ctx *context.Context) (*project_model.P
return nil, nil
}
- project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":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.ParamsInt64(":columnID"))
+ column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
if err != nil {
ctx.ServerError("GetProjectColumn", err)
return nil, nil
}
- if column.ProjectID != ctx.ParamsInt64(":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),
})
@@ -538,7 +538,7 @@ func MoveIssues(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err)
return
@@ -548,7 +548,7 @@ func MoveIssues(ctx *context.Context) {
return
}
- column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":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 ab419cc878..c52cb7ed4c 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.SetParams(":id", "4")
- ctx.SetParams(":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 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
}
diff --git a/routers/web/repo/actions/badge.go b/routers/web/repo/actions/badge.go
index 6fa951826c..e920ecaf58 100644
--- a/routers/web/repo/actions/badge.go
+++ b/routers/web/repo/actions/badge.go
@@ -17,7 +17,7 @@ import (
)
func GetWorkflowBadge(ctx *context.Context) {
- workflowFile := ctx.Params("workflow_name")
+ workflowFile := ctx.PathParam("workflow_name")
branch := ctx.Req.URL.Query().Get("branch")
if branch == "" {
branch = ctx.Repo.Repository.DefaultBranch
diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go
index 7cc12c90e6..2c62c8d9ec 100644
--- a/routers/web/repo/actions/view.go
+++ b/routers/web/repo/actions/view.go
@@ -35,8 +35,8 @@ import (
func View(ctx *context_module.Context) {
ctx.Data["PageIsActions"] = true
- runIndex := ctx.ParamsInt64("run")
- jobIndex := ctx.ParamsInt64("job")
+ runIndex := ctx.PathParamInt64("run")
+ jobIndex := ctx.PathParamInt64("job")
ctx.Data["RunIndex"] = runIndex
ctx.Data["JobIndex"] = jobIndex
ctx.Data["ActionsURL"] = ctx.Repo.RepoLink + "/actions"
@@ -130,8 +130,8 @@ type ViewStepLogLine struct {
func ViewPost(ctx *context_module.Context) {
req := web.GetForm(ctx).(*ViewRequest)
- runIndex := ctx.ParamsInt64("run")
- jobIndex := ctx.ParamsInt64("job")
+ runIndex := ctx.PathParamInt64("run")
+ jobIndex := ctx.PathParamInt64("job")
current, jobs := getRunJobs(ctx, runIndex, jobIndex)
if ctx.Written() {
@@ -268,8 +268,8 @@ func ViewPost(ctx *context_module.Context) {
// Rerun will rerun jobs in the given run
// If jobIndexStr is a blank string, it means rerun all jobs
func Rerun(ctx *context_module.Context) {
- runIndex := ctx.ParamsInt64("run")
- jobIndexStr := ctx.Params("job")
+ runIndex := ctx.PathParamInt64("run")
+ jobIndexStr := ctx.PathParam("job")
var jobIndex int64
if jobIndexStr != "" {
jobIndex, _ = strconv.ParseInt(jobIndexStr, 10, 64)
@@ -358,8 +358,8 @@ func rerunJob(ctx *context_module.Context, job *actions_model.ActionRunJob, shou
}
func Logs(ctx *context_module.Context) {
- runIndex := ctx.ParamsInt64("run")
- jobIndex := ctx.ParamsInt64("job")
+ runIndex := ctx.PathParamInt64("run")
+ jobIndex := ctx.PathParamInt64("job")
job, _ := getRunJobs(ctx, runIndex, jobIndex)
if ctx.Written() {
@@ -407,7 +407,7 @@ func Logs(ctx *context_module.Context) {
}
func Cancel(ctx *context_module.Context) {
- runIndex := ctx.ParamsInt64("run")
+ runIndex := ctx.PathParamInt64("run")
_, jobs := getRunJobs(ctx, runIndex, -1)
if ctx.Written() {
@@ -448,7 +448,7 @@ func Cancel(ctx *context_module.Context) {
}
func Approve(ctx *context_module.Context) {
- runIndex := ctx.ParamsInt64("run")
+ runIndex := ctx.PathParamInt64("run")
current, jobs := getRunJobs(ctx, runIndex, -1)
if ctx.Written() {
@@ -529,7 +529,7 @@ type ArtifactsViewItem struct {
}
func ArtifactsView(ctx *context_module.Context) {
- runIndex := ctx.ParamsInt64("run")
+ runIndex := ctx.PathParamInt64("run")
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil {
if errors.Is(err, util.ErrNotExist) {
@@ -567,8 +567,8 @@ func ArtifactsDeleteView(ctx *context_module.Context) {
return
}
- runIndex := ctx.ParamsInt64("run")
- artifactName := ctx.Params("artifact_name")
+ runIndex := ctx.PathParamInt64("run")
+ artifactName := ctx.PathParam("artifact_name")
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil {
@@ -585,8 +585,8 @@ func ArtifactsDeleteView(ctx *context_module.Context) {
}
func ArtifactsDownloadView(ctx *context_module.Context) {
- runIndex := ctx.ParamsInt64("run")
- artifactName := ctx.Params("artifact_name")
+ runIndex := ctx.PathParamInt64("run")
+ artifactName := ctx.PathParam("artifact_name")
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil {
diff --git a/routers/web/repo/activity.go b/routers/web/repo/activity.go
index 6f6641cc65..c8fa60f77a 100644
--- a/routers/web/repo/activity.go
+++ b/routers/web/repo/activity.go
@@ -24,7 +24,7 @@ func Activity(ctx *context.Context) {
ctx.Data["PageIsPulse"] = true
- ctx.Data["Period"] = ctx.Params("period")
+ ctx.Data["Period"] = ctx.PathParam("period")
timeUntil := time.Now()
var timeFrom time.Time
@@ -75,7 +75,7 @@ func ActivityAuthors(ctx *context.Context) {
timeUntil := time.Now()
var timeFrom time.Time
- switch ctx.Params("period") {
+ switch ctx.PathParam("period") {
case "daily":
timeFrom = timeUntil.Add(-time.Hour * 24)
case "halfweekly":
diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go
index 6437c39a57..0df2efeac7 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.Params(":uuid"))
+ ServeAttachment(ctx, ctx.PathParam(":uuid"))
}
diff --git a/routers/web/repo/cherry_pick.go b/routers/web/repo/cherry_pick.go
index 088f8d889d..61aff78d49 100644
--- a/routers/web/repo/cherry_pick.go
+++ b/routers/web/repo/cherry_pick.go
@@ -25,8 +25,8 @@ var tplCherryPick base.TplName = "repo/editor/cherry_pick"
// CherryPick handles cherrypick GETs
func CherryPick(ctx *context.Context) {
- ctx.Data["SHA"] = ctx.Params(":sha")
- cherryPickCommit, err := ctx.Repo.GitRepo.GetCommit(ctx.Params(":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)
@@ -38,7 +38,7 @@ func CherryPick(ctx *context.Context) {
if ctx.FormString("cherry-pick-type") == "revert" {
ctx.Data["CherryPickType"] = "revert"
- ctx.Data["commit_summary"] = "revert " + ctx.Params(":sha")
+ ctx.Data["commit_summary"] = "revert " + ctx.PathParam(":sha")
ctx.Data["commit_message"] = "revert " + cherryPickCommit.Message()
} else {
ctx.Data["CherryPickType"] = "cherry-pick"
@@ -67,7 +67,7 @@ func CherryPick(ctx *context.Context) {
func CherryPickPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.CherryPickForm)
- sha := ctx.Params(":sha")
+ sha := ctx.PathParam(":sha")
ctx.Data["SHA"] = sha
if form.Revert {
ctx.Data["CherryPickType"] = "revert"
@@ -141,7 +141,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.Params(":sha")+" does not exist."))
+ ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.PathParam(":sha")+" does not exist."))
return
}
ctx.ServerError("GetRawDiff", err)
@@ -150,7 +150,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.Params(":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 7b5e72593f..dae6063908 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -257,12 +257,12 @@ func FileHistory(ctx *context.Context) {
}
func LoadBranchesAndTags(ctx *context.Context) {
- response, err := git_service.LoadBranchesAndTags(ctx, ctx.Repo, ctx.Params("sha"))
+ response, err := git_service.LoadBranchesAndTags(ctx, ctx.Repo, ctx.PathParam("sha"))
if err == nil {
ctx.JSON(http.StatusOK, response)
return
}
- ctx.NotFoundOrServerError(fmt.Sprintf("could not load branches and tags the commit %s belongs to", ctx.Params("sha")), git.IsErrNotExist, err)
+ ctx.NotFoundOrServerError(fmt.Sprintf("could not load branches and tags the commit %s belongs to", ctx.PathParam("sha")), git.IsErrNotExist, err)
}
// Diff show different from current commit to previous commit
@@ -271,7 +271,7 @@ func Diff(ctx *context.Context) {
userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name
- commitID := ctx.Params(":sha")
+ commitID := ctx.PathParam(":sha")
var (
gitRepo *git.Repository
err error
@@ -420,13 +420,13 @@ func RawDiff(ctx *context.Context) {
}
if err := git.GetRawDiff(
gitRepo,
- ctx.Params(":sha"),
- git.RawDiffType(ctx.Params(":ext")),
+ ctx.PathParam(":sha"),
+ git.RawDiffType(ctx.PathParam(":ext")),
ctx.Resp,
); err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetRawDiff",
- errors.New("commit "+ctx.Params(":sha")+" does not exist."))
+ errors.New("commit "+ctx.PathParam(":sha")+" does not exist."))
return
}
ctx.ServerError("GetRawDiff", err)
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index 818dc4d50f..65e23bf751 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -203,7 +203,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
// 5. /{:baseOwner}/{:baseRepoName}/compare/{:headOwner}:{:headBranch}
// 6. /{:baseOwner}/{:baseRepoName}/compare/{:headOwner}/{:headRepoName}:{:headBranch}
//
- // Here we obtain the infoPath "{:baseBranch}...[{:headOwner}/{:headRepoName}:]{:headBranch}" as ctx.Params("*")
+ // Here we obtain the infoPath "{:baseBranch}...[{:headOwner}/{:headRepoName}:]{:headBranch}" as ctx.PathParam("*")
// with the :baseRepo in ctx.Repo.
//
// Note: Generally :headRepoName is not provided here - we are only passed :headOwner.
@@ -225,7 +225,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
err error
)
- infoPath = ctx.Params("*")
+ infoPath = ctx.PathParam("*")
var infos []string
if infoPath == "" {
infos = []string{baseRepo.DefaultBranch, baseRepo.DefaultBranch}
@@ -850,7 +850,7 @@ func CompareDiff(ctx *context.Context) {
// ExcerptBlob render blob excerpt contents
func ExcerptBlob(ctx *context.Context) {
- commitID := ctx.Params("sha")
+ commitID := ctx.PathParam("sha")
lastLeft := ctx.FormInt("last_left")
lastRight := ctx.FormInt("last_right")
idxLeft := ctx.FormInt("left")
diff --git a/routers/web/repo/download.go b/routers/web/repo/download.go
index 802e8e6a62..8c4da34060 100644
--- a/routers/web/repo/download.go
+++ b/routers/web/repo/download.go
@@ -139,7 +139,7 @@ func SingleDownloadOrLFS(ctx *context.Context) {
// DownloadByID download a file by sha1 ID
func DownloadByID(ctx *context.Context) {
- blob, err := ctx.Repo.GitRepo.GetBlob(ctx.Params("sha"))
+ blob, err := ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha"))
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetBlob", nil)
@@ -155,7 +155,7 @@ func DownloadByID(ctx *context.Context) {
// DownloadByIDOrLFS download a file by sha1 ID taking account of LFS
func DownloadByIDOrLFS(ctx *context.Context) {
- blob, err := ctx.Repo.GitRepo.GetBlob(ctx.Params("sha"))
+ blob, err := ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha"))
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetBlob", nil)
diff --git a/routers/web/repo/editor_test.go b/routers/web/repo/editor_test.go
index 313fcfe33a..68d69408ac 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.SetParams(":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.SetParams(":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/find.go b/routers/web/repo/find.go
index 9da4237c1e..2c44552f9c 100644
--- a/routers/web/repo/find.go
+++ b/routers/web/repo/find.go
@@ -17,7 +17,7 @@ const (
// FindFiles render the page to find repository files
func FindFiles(ctx *context.Context) {
- path := ctx.Params("*")
+ path := ctx.PathParam("*")
ctx.Data["TreeLink"] = ctx.Repo.RepoLink + "/src/" + util.PathEscapeSegments(path)
ctx.Data["DataLink"] = ctx.Repo.RepoLink + "/tree-list/" + util.PathEscapeSegments(path)
ctx.HTML(http.StatusOK, tplFindFiles)
diff --git a/routers/web/repo/githttp.go b/routers/web/repo/githttp.go
index f0579b56ea..bb85df1a86 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.Params(":username")
- reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git")
+ username := ctx.PathParam(":username")
+ reponame := strings.TrimSuffix(ctx.PathParam(":reponame"), ".git")
if ctx.FormString("go-get") == "1" {
context.EarlyResponseForGoGetMeta(ctx)
@@ -550,7 +550,7 @@ func GetTextFile(p string) func(*context.Context) {
h := httpBase(ctx)
if h != nil {
setHeaderNoCache(ctx)
- file := ctx.Params("file")
+ file := ctx.PathParam("file")
if file != "" {
h.sendFile(ctx, "text/plain", "objects/info/"+file)
} else {
@@ -575,7 +575,7 @@ func GetLooseObject(ctx *context.Context) {
if h != nil {
setHeaderCacheForever(ctx)
h.sendFile(ctx, "application/x-git-loose-object", fmt.Sprintf("objects/%s/%s",
- ctx.Params("head"), ctx.Params("hash")))
+ ctx.PathParam("head"), ctx.PathParam("hash")))
}
}
@@ -584,7 +584,7 @@ func GetPackFile(ctx *context.Context) {
h := httpBase(ctx)
if h != nil {
setHeaderCacheForever(ctx)
- h.sendFile(ctx, "application/x-git-packed-objects", "objects/pack/pack-"+ctx.Params("file")+".pack")
+ h.sendFile(ctx, "application/x-git-packed-objects", "objects/pack/pack-"+ctx.PathParam("file")+".pack")
}
}
@@ -593,6 +593,6 @@ func GetIdxFile(ctx *context.Context) {
h := httpBase(ctx)
if h != nil {
setHeaderCacheForever(ctx)
- h.sendFile(ctx, "application/x-git-packed-objects-toc", "objects/pack/pack-"+ctx.Params("file")+".idx")
+ h.sendFile(ctx, "application/x-git-packed-objects-toc", "objects/pack/pack-"+ctx.PathParam("file")+".idx")
}
}
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index e7ad02c0c2..7c4e3e36f3 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -495,7 +495,7 @@ func issueIDsFromSearch(ctx *context.Context, keyword string, opts *issues_model
// Issues render issues page
func Issues(ctx *context.Context) {
- isPullList := ctx.Params(":type") == "pulls"
+ isPullList := ctx.PathParam(":type") == "pulls"
if isPullList {
MustAllowPulls(ctx)
if ctx.Written() {
@@ -1365,13 +1365,13 @@ func getBranchData(ctx *context.Context, issue *issues_model.Issue) {
// ViewIssue render issue view page
func ViewIssue(ctx *context.Context) {
- if ctx.Params(":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.Params(":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)
@@ -1387,7 +1387,7 @@ func ViewIssue(ctx *context.Context) {
}
}
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":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)
@@ -1401,10 +1401,10 @@ func ViewIssue(ctx *context.Context) {
}
// Make sure type and URL matches.
- if ctx.Params(":type") == "issues" && issue.IsPull {
+ if ctx.PathParam(":type") == "issues" && issue.IsPull {
ctx.Redirect(issue.Link())
return
- } else if ctx.Params(":type") == "pulls" && !issue.IsPull {
+ } else if ctx.PathParam(":type") == "pulls" && !issue.IsPull {
ctx.Redirect(issue.Link())
return
}
@@ -2092,7 +2092,7 @@ func sortDependencyInfo(blockers []*issues_model.DependencyInfo) {
// 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.ParamsInt64(":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
@@ -2157,7 +2157,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.ParamsInt64(":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)
@@ -2298,7 +2298,7 @@ func UpdateIssueContent(ctx *context.Context) {
// UpdateIssueDeadline updates an issue deadline
func UpdateIssueDeadline(ctx *context.Context) {
form := web.GetForm(ctx).(*api.EditDeadlineOption)
- issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":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)
@@ -3137,7 +3137,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.ParamsInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err)
return
@@ -3222,7 +3222,7 @@ func UpdateCommentContent(ctx *context.Context) {
// DeleteComment delete comment of issue
func DeleteComment(ctx *context.Context) {
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err)
return
@@ -3290,7 +3290,7 @@ func ChangeIssueReaction(ctx *context.Context) {
return
}
- switch ctx.Params(":action") {
+ switch ctx.PathParam(":action") {
case "react":
reaction, err := issue_service.CreateIssueReaction(ctx, ctx.Doer, issue, form.Content)
if err != nil {
@@ -3324,7 +3324,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.Params(":action")), nil)
+ ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam(":action")), nil)
return
}
@@ -3352,7 +3352,7 @@ func ChangeIssueReaction(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.ParamsInt64(":id"))
+ comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err)
return
@@ -3396,7 +3396,7 @@ func ChangeCommentReaction(ctx *context.Context) {
return
}
- switch ctx.Params(":action") {
+ switch ctx.PathParam(":action") {
case "react":
reaction, err := issue_service.CreateCommentReaction(ctx, ctx.Doer, comment, form.Content)
if err != nil {
@@ -3430,7 +3430,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.Params(":action")), nil)
+ ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam(":action")), nil)
return
}
@@ -3504,7 +3504,7 @@ func GetIssueAttachments(ctx *context.Context) {
// GetCommentAttachments returns attachments for the comment
func GetCommentAttachments(ctx *context.Context) {
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":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_dependency.go b/routers/web/repo/issue_dependency.go
index e3b85ee638..f1d133edb0 100644
--- a/routers/web/repo/issue_dependency.go
+++ b/routers/web/repo/issue_dependency.go
@@ -14,7 +14,7 @@ import (
// AddDependency adds new dependencies
func AddDependency(ctx *context.Context) {
- issueIndex := ctx.ParamsInt64("index")
+ issueIndex := ctx.PathParamInt64("index")
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, issueIndex)
if err != nil {
ctx.ServerError("GetIssueByIndex", err)
@@ -88,7 +88,7 @@ func AddDependency(ctx *context.Context) {
// RemoveDependency removes the dependency
func RemoveDependency(ctx *context.Context) {
- issueIndex := ctx.ParamsInt64("index")
+ issueIndex := ctx.PathParamInt64("index")
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, issueIndex)
if err != nil {
ctx.ServerError("GetIssueByIndex", err)
diff --git a/routers/web/repo/issue_pin.go b/routers/web/repo/issue_pin.go
index 365c812681..0074e31f03 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.ParamsInt64(":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 241e434049..099711c5e9 100644
--- a/routers/web/repo/issue_timetrack.go
+++ b/routers/web/repo/issue_timetrack.go
@@ -61,7 +61,7 @@ func DeleteTime(c *context.Context) {
return
}
- t, err := issues_model.GetTrackedTimeByID(c, c.ParamsInt64(":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/milestone.go b/routers/web/repo/milestone.go
index c6c8cb5cfb..e4ee025875 100644
--- a/routers/web/repo/milestone.go
+++ b/routers/web/repo/milestone.go
@@ -165,7 +165,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.ParamsInt64(":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)
@@ -205,7 +205,7 @@ func EditMilestonePost(ctx *context.Context) {
}
deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location())
- m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":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)
@@ -229,7 +229,7 @@ func EditMilestonePost(ctx *context.Context) {
// ChangeMilestoneStatus response for change a milestone's status
func ChangeMilestoneStatus(ctx *context.Context) {
var toClose bool
- switch ctx.Params(":action") {
+ switch ctx.PathParam(":action") {
case "open":
toClose = false
case "close":
@@ -238,7 +238,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones")
return
}
- id := ctx.ParamsInt64(":id")
+ id := ctx.PathParamInt64(":id")
if err := issues_model.ChangeMilestoneStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
@@ -248,7 +248,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
}
return
}
- ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.Params(":action")))
+ ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.PathParam(":action")))
}
// DeleteMilestone delete a milestone
@@ -264,7 +264,7 @@ func DeleteMilestone(ctx *context.Context) {
// MilestoneIssuesAndPulls lists all the issues and pull requests of the milestone
func MilestoneIssuesAndPulls(ctx *context.Context) {
- milestoneID := ctx.ParamsInt64(":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 2e32f478aa..fdeead5703 100644
--- a/routers/web/repo/projects.go
+++ b/routers/web/repo/projects.go
@@ -170,7 +170,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.Params(":action") {
+ switch ctx.PathParam(":action") {
case "open":
toClose = false
case "close":
@@ -179,7 +179,7 @@ func ChangeProjectStatus(ctx *context.Context) {
ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects")
return
}
- id := ctx.ParamsInt64(":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)
@@ -190,7 +190,7 @@ func ChangeProjectStatus(ctx *context.Context) {
// DeleteProject delete a project
func DeleteProject(ctx *context.Context) {
- p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -220,7 +220,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.ParamsInt64(":id"))
+ p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -247,7 +247,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.ParamsInt64(":id")
+ projectID := ctx.PathParamInt64(":id")
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
ctx.Data["PageIsEditProjects"] = true
@@ -292,7 +292,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.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -424,7 +424,7 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -434,12 +434,12 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- pb, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":columnID"))
+ pb, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
if err != nil {
ctx.ServerError("GetProjectColumn", err)
return
}
- if pb.ProjectID != ctx.ParamsInt64(":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),
})
@@ -453,7 +453,7 @@ func DeleteProjectColumn(ctx *context.Context) {
return
}
- if err := project_model.DeleteColumnByID(ctx, ctx.ParamsInt64(":columnID")); err != nil {
+ if err := project_model.DeleteColumnByID(ctx, ctx.PathParamInt64(":columnID")); err != nil {
ctx.ServerError("DeleteProjectColumnByID", err)
return
}
@@ -471,7 +471,7 @@ func AddColumnToProjectPost(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectForRepoByID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":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)
@@ -509,7 +509,7 @@ func checkProjectColumnChangePermissions(ctx *context.Context) (*project_model.P
return nil, nil
}
- project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
@@ -519,12 +519,12 @@ func checkProjectColumnChangePermissions(ctx *context.Context) (*project_model.P
return nil, nil
}
- column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":columnID"))
+ column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID"))
if err != nil {
ctx.ServerError("GetProjectColumn", err)
return nil, nil
}
- if column.ProjectID != ctx.ParamsInt64(":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),
})
@@ -595,7 +595,7 @@ func MoveIssues(ctx *context.Context) {
return
}
- project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
+ project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("ProjectNotExist", nil)
@@ -609,7 +609,7 @@ func MoveIssues(ctx *context.Context) {
return
}
- column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":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 d61230a57e..1a42c615ab 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.SetParams(":id", "1")
- ctx.SetParams(":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 92e0a1674e..4522099460 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.ParamsInt64(":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)
@@ -886,15 +886,15 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
}
func ViewPullFilesForSingleCommit(ctx *context.Context) {
- viewPullFiles(ctx, "", ctx.Params("sha"), true, true)
+ viewPullFiles(ctx, "", ctx.PathParam("sha"), true, true)
}
func ViewPullFilesForRange(ctx *context.Context) {
- viewPullFiles(ctx, ctx.Params("shaFrom"), ctx.Params("shaTo"), true, false)
+ viewPullFiles(ctx, ctx.PathParam("shaFrom"), ctx.PathParam("shaTo"), true, false)
}
func ViewPullFilesStartingFromCommit(ctx *context.Context) {
- viewPullFiles(ctx, "", ctx.Params("sha"), true, false)
+ viewPullFiles(ctx, "", ctx.PathParam("sha"), true, false)
}
func ViewPullFilesForAllCommitsOfPr(ctx *context.Context) {
@@ -1493,7 +1493,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.ParamsInt64(":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)
@@ -1586,7 +1586,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.ParamsInt64(":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/release.go b/routers/web/repo/release.go
index 8ba2adf3f1..85c7828f2e 100644
--- a/routers/web/repo/release.go
+++ b/routers/web/repo/release.go
@@ -286,7 +286,7 @@ func SingleRelease(ctx *context.Context) {
releases, err := getReleaseInfos(ctx, &repo_model.FindReleasesOptions{
ListOptions: db.ListOptions{Page: 1, PageSize: 1},
RepoID: ctx.Repo.Repository.ID,
- TagNames: []string{ctx.Params("*")},
+ TagNames: []string{ctx.PathParam("*")},
// only show draft releases for users who can write, read-only users shouldn't see draft releases.
IncludeDrafts: writeAccess,
IncludeTags: true,
@@ -528,7 +528,7 @@ func EditRelease(ctx *context.Context) {
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
upload.AddUploadContext(ctx, "release")
- tagName := ctx.Params("*")
+ tagName := ctx.PathParam("*")
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
@@ -571,7 +571,7 @@ func EditReleasePost(ctx *context.Context) {
ctx.Data["PageIsReleaseList"] = true
ctx.Data["PageIsEditRelease"] = true
- tagName := ctx.Params("*")
+ tagName := ctx.PathParam("*")
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 92f74bbf33..70dcbae0e1 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -312,7 +312,7 @@ const (
// Action response for actions to a repository
func Action(ctx *context.Context) {
var err error
- switch ctx.Params(":action") {
+ switch ctx.PathParam(":action") {
case "watch":
err = repo_model.WatchRepo(ctx, ctx.Doer, ctx.Repo.Repository, true)
case "unwatch":
@@ -340,29 +340,29 @@ 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.Params(":action")), err)
+ ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam(":action")), err)
return
}
}
- switch ctx.Params(":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":
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
}
- switch ctx.Params(":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.Params(":action")), err)
+ ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam(":action")), err)
return
}
}
- switch ctx.Params(":action") {
+ switch ctx.PathParam(":action") {
case "watch", "unwatch":
ctx.HTML(http.StatusOK, tplWatchUnwatch)
return
@@ -412,8 +412,8 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {
// RedirectDownload return a file based on the following infos:
func RedirectDownload(ctx *context.Context) {
var (
- vTag = ctx.Params("vTag")
- fileName = ctx.Params("fileName")
+ vTag = ctx.PathParam("vTag")
+ fileName = ctx.PathParam("fileName")
)
tagNames := []string{vTag}
curRepo := ctx.Repo.Repository
@@ -460,7 +460,7 @@ func RedirectDownload(ctx *context.Context) {
// Download an archive of a repository
func Download(ctx *context.Context) {
- uri := ctx.Params("*")
+ uri := ctx.PathParam("*")
aReq, err := archiver_service.NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, uri)
if err != nil {
if errors.Is(err, archiver_service.ErrUnknownArchiveFormat{}) {
@@ -519,7 +519,7 @@ func download(ctx *context.Context, archiveName string, archiver *repo_model.Rep
// a request that's already in-progress, but the archiver service will just
// kind of drop it on the floor if this is the case.
func InitiateDownload(ctx *context.Context) {
- uri := ctx.Params("*")
+ uri := ctx.PathParam("*")
aReq, err := archiver_service.NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, uri)
if err != nil {
ctx.ServerError("archiver_service.NewRequest", err)
diff --git a/routers/web/repo/setting/git_hooks.go b/routers/web/repo/setting/git_hooks.go
index 217a01c90c..2e9caa4c86 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.Params(":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.Params(":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/lfs.go b/routers/web/repo/setting/lfs.go
index 2891556d6f..3b96f93ff2 100644
--- a/routers/web/repo/setting/lfs.go
+++ b/routers/web/repo/setting/lfs.go
@@ -236,7 +236,7 @@ func LFSUnlock(ctx *context.Context) {
ctx.NotFound("LFSUnlock", nil)
return
}
- _, err := git_model.DeleteLFSLockByID(ctx, ctx.ParamsInt64("lid"), ctx.Repo.Repository, ctx.Doer, true)
+ _, err := git_model.DeleteLFSLockByID(ctx, ctx.PathParamInt64("lid"), ctx.Repo.Repository, ctx.Doer, true)
if err != nil {
ctx.ServerError("LFSUnlock", err)
return
@@ -251,7 +251,7 @@ func LFSFileGet(ctx *context.Context) {
return
}
ctx.Data["LFSFilesLink"] = ctx.Repo.RepoLink + "/settings/lfs"
- oid := ctx.Params("oid")
+ oid := ctx.PathParam("oid")
p := lfs.Pointer{Oid: oid}
if !p.IsValid() {
@@ -348,7 +348,7 @@ func LFSDelete(ctx *context.Context) {
ctx.NotFound("LFSDelete", nil)
return
}
- oid := ctx.Params("oid")
+ oid := ctx.PathParam("oid")
p := lfs.Pointer{Oid: oid}
if !p.IsValid() {
ctx.NotFound("LFSDelete", nil)
diff --git a/routers/web/repo/setting/protected_branch.go b/routers/web/repo/setting/protected_branch.go
index 4bab3f897a..400186db67 100644
--- a/routers/web/repo/setting/protected_branch.go
+++ b/routers/web/repo/setting/protected_branch.go
@@ -266,7 +266,7 @@ func SettingsProtectedBranchPost(ctx *context.Context) {
// DeleteProtectedBranchRulePost delete protected branch rule by id
func DeleteProtectedBranchRulePost(ctx *context.Context) {
- ruleID := ctx.ParamsInt64("id")
+ ruleID := ctx.PathParamInt64("id")
if ruleID <= 0 {
ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID)))
ctx.JSONRedirect(fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink))
diff --git a/routers/web/repo/setting/protected_tag.go b/routers/web/repo/setting/protected_tag.go
index 2c25b650b9..fcfa77aa8c 100644
--- a/routers/web/repo/setting/protected_tag.go
+++ b/routers/web/repo/setting/protected_tag.go
@@ -169,7 +169,7 @@ func setTagsContext(ctx *context.Context) error {
func selectProtectedTagByContext(ctx *context.Context) *git_model.ProtectedTag {
id := ctx.FormInt64("id")
if id == 0 {
- id = ctx.ParamsInt64(":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 a47d3b45e2..93e6f518b0 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.ParamsInt64(":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.ParamsInt64(":runnerid"),
+ actions_shared.RunnerDetailsEditPost(ctx, ctx.PathParamInt64(":runnerid"),
rCtx.OwnerID, rCtx.RepoID,
- rCtx.RedirectLink+url.PathEscape(ctx.Params(":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.ParamsInt64(":runnerid"), rCtx.RedirectLink, rCtx.RedirectLink+url.PathEscape(ctx.Params(":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 1a3549fea4..7661599729 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.Params(":configType") == "system-hooks",
+ IsSystemWebhook: ctx.PathParam(":configType") == "system-hooks",
Link: path.Join(setting.AppSubURL, "/admin/hooks"),
- LinkNew: path.Join(setting.AppSubURL, "/admin/", ctx.Params(":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.Params(":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.ParamsInt64(":id"))
+ w, err = webhook.GetWebhookByRepoID(ctx, orCtx.RepoID, ctx.PathParamInt64(":id"))
} else if orCtx.OwnerID > 0 {
- w, err = webhook.GetWebhookByOwnerID(ctx, orCtx.OwnerID, ctx.ParamsInt64(":id"))
+ w, err = webhook.GetWebhookByOwnerID(ctx, orCtx.OwnerID, ctx.PathParamInt64(":id"))
} else if orCtx.IsAdmin {
- w, err = webhook.GetSystemOrDefaultWebhook(ctx, ctx.ParamsInt64(":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.ParamsInt64(":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.Params(":uuid")
+ hookTaskUUID := ctx.PathParam(":uuid")
orCtx, w := checkWebhook(ctx)
if ctx.Written() {
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index 2c478abacf..203dac7439 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -772,7 +772,7 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
// Home render repository home page
func Home(ctx *context.Context) {
if setting.Other.EnableFeed {
- isFeed, _, showFeedType := feed.GetFeedType(ctx.Params(":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/repo/wiki_test.go b/routers/web/repo/wiki_test.go
index 4602dcfeb4..7de5899e21 100644
--- a/routers/web/repo/wiki_test.go
+++ b/routers/web/repo/wiki_test.go
@@ -81,7 +81,7 @@ func TestWiki(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki")
- ctx.SetParams("*", "Home")
+ ctx.SetPathParam("*", "Home")
contexttest.LoadRepo(t, ctx, 1)
Wiki(ctx)
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
@@ -153,7 +153,7 @@ func TestEditWiki(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_edit")
- ctx.SetParams("*", "Home")
+ ctx.SetPathParam("*", "Home")
contexttest.LoadUser(t, ctx, 2)
contexttest.LoadRepo(t, ctx, 1)
EditWiki(ctx)
@@ -169,7 +169,7 @@ func TestEditWikiPost(t *testing.T) {
} {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_new")
- ctx.SetParams("*", "Home")
+ ctx.SetPathParam("*", "Home")
contexttest.LoadUser(t, ctx, 2)
contexttest.LoadRepo(t, ctx, 1)
web.SetForm(ctx, &forms.NewWikiForm{
@@ -211,7 +211,7 @@ func TestWikiRaw(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/raw/"+url.PathEscape(filepath))
- ctx.SetParams("*", filepath)
+ ctx.SetPathParam("*", filepath)
contexttest.LoadUser(t, ctx, 2)
contexttest.LoadRepo(t, ctx, 1)
WikiRaw(ctx)
@@ -236,7 +236,7 @@ func TestDefaultWikiBranch(t *testing.T) {
assert.NoError(t, repo_model.UpdateRepositoryCols(db.DefaultContext, &repo_model.Repository{ID: 1, DefaultWikiBranch: "wrong-branch"}))
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki")
- ctx.SetParams("*", "Home")
+ ctx.SetPathParam("*", "Home")
contexttest.LoadRepo(t, ctx, 1)
assert.Equal(t, "wrong-branch", ctx.Repo.Repository.DefaultWikiBranch)
Wiki(ctx) // after the visiting, the out-of-sync database record will update the branch name to "master"
diff --git a/routers/web/shared/actions/variables.go b/routers/web/shared/actions/variables.go
index 79c03e4e8c..5c5768243a 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.ParamsInt64(":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.ParamsInt64(":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/packages/packages.go b/routers/web/shared/packages/packages.go
index 57671ad8f1..1d3cabf71b 100644
--- a/routers/web/shared/packages/packages.go
+++ b/routers/web/shared/packages/packages.go
@@ -204,7 +204,7 @@ func SetRulePreviewContext(ctx *context.Context, owner *user_model.User) {
func getCleanupRuleByContext(ctx *context.Context, owner *user_model.User) *packages_model.PackageCleanupRule {
id := ctx.FormInt64("id")
if id == 0 {
- id = ctx.ParamsInt64("id")
+ id = ctx.PathParamInt64("id")
}
pcr, err := packages_model.GetCleanupRuleByID(ctx, id)
diff --git a/routers/web/shared/project/column.go b/routers/web/shared/project/column.go
index 599842ea9e..ba1f527bea 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.ParamsInt64(":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 04f510161d..7000e25778 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.Params(":username")
- size := int(ctx.ParamsInt64(":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.Params(":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 b03a514030..e94433b3c5 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -50,7 +50,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.Params(":org")
+ orgName := ctx.PathParam(":org")
if len(orgName) > 0 {
ctxUser = ctx.Org.Organization.AsUser()
ctx.Data["Teams"] = ctx.Org.Teams
@@ -714,9 +714,9 @@ func ShowGPGKeys(ctx *context.Context) {
func UsernameSubRoute(ctx *context.Context) {
// WORKAROUND to support usernames with "." in it
// https://github.com/go-chi/chi/issues/781
- username := ctx.Params("username")
+ username := ctx.PathParam("username")
reloadParam := func(suffix string) (success bool) {
- ctx.SetParams("username", strings.TrimSuffix(username, suffix))
+ ctx.SetPathParam("username", strings.TrimSuffix(username, suffix))
context.UserAssignmentWeb()(ctx)
if ctx.Written() {
return false
diff --git a/routers/web/user/home_test.go b/routers/web/user/home_test.go
index 1cc9886308..51246551ea 100644
--- a/routers/web/user/home_test.go
+++ b/routers/web/user/home_test.go
@@ -83,7 +83,7 @@ func TestMilestones(t *testing.T) {
ctx, _ := contexttest.MockContext(t, "milestones")
contexttest.LoadUser(t, ctx, 2)
- ctx.SetParams("sort", "issues")
+ ctx.SetPathParam("sort", "issues")
ctx.Req.Form.Set("state", "closed")
ctx.Req.Form.Set("sort", "furthestduedate")
Milestones(ctx)
@@ -102,8 +102,8 @@ func TestMilestonesForSpecificRepo(t *testing.T) {
ctx, _ := contexttest.MockContext(t, "milestones")
contexttest.LoadUser(t, ctx, 2)
- ctx.SetParams("sort", "issues")
- ctx.SetParams("repo", "1")
+ ctx.SetPathParam("sort", "issues")
+ ctx.SetPathParam("repo", "1")
ctx.Req.Form.Set("state", "closed")
ctx.Req.Form.Set("sort", "furthestduedate")
Milestones(ctx)
diff --git a/routers/web/user/package.go b/routers/web/user/package.go
index dad4c8f602..4e39eabc0f 100644
--- a/routers/web/user/package.go
+++ b/routers/web/user/package.go
@@ -136,7 +136,7 @@ func ListPackages(ctx *context.Context) {
// RedirectToLastVersion redirects to the latest package version
func RedirectToLastVersion(ctx *context.Context) {
- p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.Type(ctx.Params("type")), ctx.Params("name"))
+ p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.Type(ctx.PathParam("type")), ctx.PathParam("name"))
if err != nil {
if err == packages_model.ErrPackageNotExist {
ctx.NotFound("GetPackageByName", err)
@@ -298,7 +298,7 @@ func ViewPackageVersion(ctx *context.Context) {
// ListPackageVersions lists all versions of a package
func ListPackageVersions(ctx *context.Context) {
shared_user.PrepareContextForProfileBigAvatar(ctx)
- p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.Type(ctx.Params("type")), ctx.Params("name"))
+ p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.Type(ctx.PathParam("type")), ctx.PathParam("name"))
if err != nil {
if err == packages_model.ErrPackageNotExist {
ctx.NotFound("GetPackageByName", err)
@@ -485,7 +485,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.ParamsInt64(":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)
diff --git a/routers/web/user/setting/oauth2_common.go b/routers/web/user/setting/oauth2_common.go
index 85d1e820a5..4477dc570f 100644
--- a/routers/web/user/setting/oauth2_common.go
+++ b/routers/web/user/setting/oauth2_common.go
@@ -73,7 +73,7 @@ func (oa *OAuth2CommonHandlers) AddApp(ctx *context.Context) {
// EditShow displays the given application
func (oa *OAuth2CommonHandlers) EditShow(ctx *context.Context) {
- app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.ParamsInt64("id"))
+ app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if auth.IsErrOAuthApplicationNotFound(err) {
ctx.NotFound("Application not found", err)
@@ -102,7 +102,7 @@ func (oa *OAuth2CommonHandlers) EditSave(ctx *context.Context) {
// TODO validate redirect URI
var err error
if ctx.Data["App"], err = auth.UpdateOAuth2Application(ctx, auth.UpdateOAuth2ApplicationOptions{
- ID: ctx.ParamsInt64("id"),
+ ID: ctx.PathParamInt64("id"),
Name: form.Name,
RedirectURIs: util.SplitTrimSpace(form.RedirectURIs, "\n"),
UserID: oa.OwnerID,
@@ -117,7 +117,7 @@ func (oa *OAuth2CommonHandlers) EditSave(ctx *context.Context) {
// RegenerateSecret regenerates the secret
func (oa *OAuth2CommonHandlers) RegenerateSecret(ctx *context.Context) {
- app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.ParamsInt64("id"))
+ app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if auth.IsErrOAuthApplicationNotFound(err) {
ctx.NotFound("Application not found", err)
@@ -142,7 +142,7 @@ func (oa *OAuth2CommonHandlers) RegenerateSecret(ctx *context.Context) {
// DeleteApp deletes the given oauth2 application
func (oa *OAuth2CommonHandlers) DeleteApp(ctx *context.Context) {
- if err := auth.DeleteOAuth2Application(ctx, ctx.ParamsInt64("id"), oa.OwnerID); err != nil {
+ if err := auth.DeleteOAuth2Application(ctx, ctx.PathParamInt64("id"), oa.OwnerID); err != nil {
ctx.ServerError("DeleteOAuth2Application", err)
return
}
@@ -153,7 +153,7 @@ func (oa *OAuth2CommonHandlers) DeleteApp(ctx *context.Context) {
// RevokeGrant revokes the grant
func (oa *OAuth2CommonHandlers) RevokeGrant(ctx *context.Context) {
- if err := auth.RevokeOAuth2Grant(ctx, ctx.ParamsInt64("grantId"), oa.OwnerID); err != nil {
+ if err := auth.RevokeOAuth2Grant(ctx, ctx.PathParamInt64("grantId"), oa.OwnerID); err != nil {
ctx.ServerError("RevokeOAuth2Grant", err)
return
}
diff --git a/routers/web/user/task.go b/routers/web/user/task.go
index 8476767e9e..475ef16212 100644
--- a/routers/web/user/task.go
+++ b/routers/web/user/task.go
@@ -14,11 +14,11 @@ import (
// TaskStatus returns task's status
func TaskStatus(ctx *context.Context) {
- task, opts, err := admin_model.GetMigratingTaskByID(ctx, ctx.ParamsInt64("task"), ctx.Doer.ID)
+ task, opts, err := admin_model.GetMigratingTaskByID(ctx, ctx.PathParamInt64("task"), ctx.Doer.ID)
if err != nil {
if admin_model.IsErrTaskDoesNotExist(err) {
ctx.JSON(http.StatusNotFound, map[string]any{
- "error": "task `" + strconv.FormatInt(ctx.ParamsInt64("task"), 10) + "` does not exist",
+ "error": "task `" + strconv.FormatInt(ctx.PathParamInt64("task"), 10) + "` does not exist",
})
return
}
diff --git a/routers/web/web.go b/routers/web/web.go
index 715b5d1512..9f9a1bb098 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -226,8 +226,8 @@ func ctxDataSet(args ...any) func(ctx *context.Context) {
}
// Routes returns all web routes
-func Routes() *web.Route {
- routes := web.NewRoute()
+func Routes() *web.Router {
+ routes := web.NewRouter()
routes.Head("/", misc.DummyOK) // for health check - doesn't need to be passed through gzip handler
routes.Methods("GET, HEAD, OPTIONS", "/assets/*", optionsCorsHandler(), public.FileHandlerFunc())
@@ -283,7 +283,7 @@ func Routes() *web.Route {
mid = append(mid, repo.GetActiveStopwatch)
mid = append(mid, goGet)
- others := web.NewRoute()
+ others := web.NewRouter()
others.Use(mid...)
registerRoutes(others)
routes.Mount("", others)
@@ -293,7 +293,7 @@ func Routes() *web.Route {
var ignSignInAndCsrf = verifyAuthWithOptions(&common.VerifyOptions{DisableCSRF: true})
// registerRoutes register routes
-func registerRoutes(m *web.Route) {
+func registerRoutes(m *web.Router) {
reqSignIn := verifyAuthWithOptions(&common.VerifyOptions{SignInRequired: true})
reqSignOut := verifyAuthWithOptions(&common.VerifyOptions{SignOutRequired: true})
// TODO: rename them to "optSignIn", which means that the "sign-in" could be optional, depends on the VerifyOptions (RequireSignInView)
diff --git a/services/context/api.go b/services/context/api.go
index c684add297..84da526e74 100644
--- a/services/context/api.go
+++ b/services/context/api.go
@@ -317,7 +317,7 @@ func RepoRefForAPI(next http.Handler) http.Handler {
}
ctx.Repo.Commit = commit
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
- ctx.Repo.TreePath = ctx.Params("*")
+ ctx.Repo.TreePath = ctx.PathParam("*")
next.ServeHTTP(w, req)
return
}
@@ -347,7 +347,7 @@ func RepoRefForAPI(next http.Handler) http.Handler {
return
}
} else {
- ctx.NotFound(fmt.Errorf("not exist: '%s'", ctx.Params("*")))
+ ctx.NotFound(fmt.Errorf("not exist: '%s'", ctx.PathParam("*")))
return
}
diff --git a/services/context/base.go b/services/context/base.go
index ccccee8c37..68619bf067 100644
--- a/services/context/base.go
+++ b/services/context/base.go
@@ -143,8 +143,8 @@ func (b *Base) RemoteAddr() string {
return b.Req.RemoteAddr
}
-// Params returns the param in request path, eg: "/{var}" => "/a%2fb", then `var == "a/b"`
-func (b *Base) Params(name string) string {
+// PathParam returns the param in request path, eg: "/{var}" => "/a%2fb", then `var == "a/b"`
+func (b *Base) PathParam(name string) string {
s, err := url.PathUnescape(b.PathParamRaw(name))
if err != nil && !setting.IsProd {
panic("Failed to unescape path param: " + err.Error() + ", there seems to be a double-unescaping bug")
@@ -157,14 +157,14 @@ func (b *Base) PathParamRaw(name string) string {
return chi.URLParam(b.Req, strings.TrimPrefix(name, ":"))
}
-// ParamsInt64 returns the param in request path as int64
-func (b *Base) ParamsInt64(p string) int64 {
- v, _ := strconv.ParseInt(b.Params(p), 10, 64)
+// PathParamInt64 returns the param in request path as int64
+func (b *Base) PathParamInt64(p string) int64 {
+ v, _ := strconv.ParseInt(b.PathParam(p), 10, 64)
return v
}
-// SetParams set request path params into routes
-func (b *Base) SetParams(k, v string) {
+// SetPathParam set request path params into routes
+func (b *Base) SetPathParam(k, v string) {
chiCtx := chi.RouteContext(b)
chiCtx.URLParams.Add(strings.TrimPrefix(k, ":"), url.PathEscape(v))
}
diff --git a/services/context/org.go b/services/context/org.go
index 018b76de43..7eba80ff96 100644
--- a/services/context/org.go
+++ b/services/context/org.go
@@ -41,7 +41,7 @@ func (org *Organization) CanReadUnit(ctx *Context, unitType unit.Type) bool {
}
func GetOrganizationByParams(ctx *Context) {
- orgName := ctx.Params(":org")
+ orgName := ctx.PathParam(":org")
var err error
@@ -221,7 +221,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
ctx.Data["NumTeams"] = len(ctx.Org.Teams)
}
- teamName := ctx.Params(":team")
+ teamName := ctx.PathParam(":team")
if len(teamName) > 0 {
teamExists := false
for _, team := range ctx.Org.Teams {
diff --git a/services/context/package.go b/services/context/package.go
index c452c657e7..271b61e99c 100644
--- a/services/context/package.go
+++ b/services/context/package.go
@@ -68,9 +68,9 @@ func packageAssignment(ctx *packageAssignmentCtx, errCb func(int, string, any))
return pkg
}
- packageType := ctx.Params("type")
- name := ctx.Params("name")
- version := ctx.Params("version")
+ packageType := ctx.PathParam("type")
+ name := ctx.PathParam("name")
+ version := ctx.PathParam("version")
if packageType != "" && name != "" && version != "" {
pv, err := packages_model.GetVersionByNameAndVersion(ctx, pkg.Owner.ID, packages_model.Type(packageType), name, version)
if err != nil {
diff --git a/services/context/repo.go b/services/context/repo.go
index 47cbf4ffda..e0d3a0bfd3 100644
--- a/services/context/repo.go
+++ b/services/context/repo.go
@@ -319,8 +319,8 @@ func ComposeGoGetImport(owner, repo string) string {
// This is particular a workaround for "go get" command which does not respect
// .netrc file.
func EarlyResponseForGoGetMeta(ctx *Context) {
- username := ctx.Params(":username")
- reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git")
+ username := ctx.PathParam(":username")
+ reponame := strings.TrimSuffix(ctx.PathParam(":reponame"), ".git")
if username == "" || reponame == "" {
ctx.PlainText(http.StatusBadRequest, "invalid repository path")
return
@@ -339,8 +339,8 @@ func EarlyResponseForGoGetMeta(ctx *Context) {
// RedirectToRepo redirect to a differently-named repository
func RedirectToRepo(ctx *Base, redirectRepoID int64) {
- ownerName := ctx.Params(":username")
- previousRepoName := ctx.Params(":reponame")
+ ownerName := ctx.PathParam(":username")
+ previousRepoName := ctx.PathParam(":reponame")
repo, err := repo_model.GetRepositoryByID(ctx, redirectRepoID)
if err != nil {
@@ -419,8 +419,8 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
err error
)
- userName := ctx.Params(":username")
- repoName := ctx.Params(":reponame")
+ userName := ctx.PathParam(":username")
+ repoName := ctx.PathParam(":reponame")
repoName = strings.TrimSuffix(repoName, ".git")
if setting.Other.EnableFeed {
repoName = strings.TrimSuffix(repoName, ".rss")
@@ -463,7 +463,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
if strings.HasSuffix(repoName, ".wiki") {
// ctx.Req.URL.Path does not have the preceding appSubURL - any redirect must have this added
// Now we happen to know that all of our paths are: /:username/:reponame/whatever_else
- originalRepoName := ctx.Params(":reponame")
+ originalRepoName := ctx.PathParam(":reponame")
redirectRepoName := strings.TrimSuffix(repoName, ".wiki")
redirectRepoName += originalRepoName[len(redirectRepoName)+5:]
redirectPath := strings.Replace(
@@ -801,7 +801,7 @@ func getRefNameFromPath(repo *Repository, path string, isExist func(string) bool
}
func getRefName(ctx *Base, repo *Repository, pathType RepoRefType) string {
- path := ctx.Params("*")
+ path := ctx.PathParam("*")
switch pathType {
case RepoRefLegacy, RepoRefAny:
if refName := getRefName(ctx, repo, RepoRefBranch); len(refName) > 0 {
@@ -917,7 +917,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
}
// Get default branch.
- if len(ctx.Params("*")) == 0 {
+ if len(ctx.PathParam("*")) == 0 {
refName = ctx.Repo.Repository.DefaultBranch
if !ctx.Repo.GitRepo.IsBranchExist(refName) {
brs, _, err := ctx.Repo.GitRepo.GetBranches(0, 1)
@@ -1005,7 +1005,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
if refType == RepoRefLegacy {
// redirect from old URL scheme to new URL scheme
- prefix := strings.TrimPrefix(setting.AppSubURL+strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ctx.Params("*"))), strings.ToLower(ctx.Repo.RepoLink))
+ prefix := strings.TrimPrefix(setting.AppSubURL+strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ctx.PathParam("*"))), strings.ToLower(ctx.Repo.RepoLink))
redirect := path.Join(
ctx.Repo.RepoLink,
util.PathEscapeSegments(prefix),
diff --git a/services/context/upload/upload.go b/services/context/upload/upload.go
index 77a7eb9377..7123420e99 100644
--- a/services/context/upload/upload.go
+++ b/services/context/upload/upload.go
@@ -86,8 +86,8 @@ func AddUploadContext(ctx *context.Context, uploadType string) {
} else if uploadType == "comment" {
ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/issues/attachments"
ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/issues/attachments/remove"
- if len(ctx.Params(":index")) > 0 {
- ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/" + url.PathEscape(ctx.Params(":index")) + "/attachments"
+ if len(ctx.PathParam(":index")) > 0 {
+ ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/" + url.PathEscape(ctx.PathParam(":index")) + "/attachments"
} else {
ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/attachments"
}
diff --git a/services/context/user.go b/services/context/user.go
index 4c9cd2928b..b0e855e923 100644
--- a/services/context/user.go
+++ b/services/context/user.go
@@ -33,7 +33,7 @@ func UserAssignmentWeb() func(ctx *Context) {
// UserIDAssignmentAPI returns a middleware to handle context-user assignment for api routes
func UserIDAssignmentAPI() func(ctx *APIContext) {
return func(ctx *APIContext) {
- userID := ctx.ParamsInt64(":user-id")
+ userID := ctx.PathParamInt64(":user-id")
if ctx.IsSigned && ctx.Doer.ID == userID {
ctx.ContextUser = ctx.Doer
@@ -59,7 +59,7 @@ func UserAssignmentAPI() func(ctx *APIContext) {
}
func userAssignment(ctx *Base, doer *user_model.User, errCb func(int, string, any)) (contextUser *user_model.User) {
- username := ctx.Params(":username")
+ username := ctx.PathParam(":username")
if doer != nil && doer.LowerName == strings.ToLower(username) {
contextUser = doer
diff --git a/services/lfs/locks.go b/services/lfs/locks.go
index 2a362b1c0d..4254c99383 100644
--- a/services/lfs/locks.go
+++ b/services/lfs/locks.go
@@ -136,8 +136,8 @@ func GetListLockHandler(ctx *context.Context) {
// PostLockHandler create lock
func PostLockHandler(ctx *context.Context) {
- userName := ctx.Params("username")
- repoName := strings.TrimSuffix(ctx.Params("reponame"), ".git")
+ userName := ctx.PathParam("username")
+ repoName := strings.TrimSuffix(ctx.PathParam("reponame"), ".git")
authorization := ctx.Req.Header.Get("Authorization")
repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, userName, repoName)
@@ -208,8 +208,8 @@ func PostLockHandler(ctx *context.Context) {
// VerifyLockHandler list locks for verification
func VerifyLockHandler(ctx *context.Context) {
- userName := ctx.Params("username")
- repoName := strings.TrimSuffix(ctx.Params("reponame"), ".git")
+ userName := ctx.PathParam("username")
+ repoName := strings.TrimSuffix(ctx.PathParam("reponame"), ".git")
authorization := ctx.Req.Header.Get("Authorization")
repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, userName, repoName)
@@ -279,8 +279,8 @@ func VerifyLockHandler(ctx *context.Context) {
// UnLockHandler delete locks
func UnLockHandler(ctx *context.Context) {
- userName := ctx.Params("username")
- repoName := strings.TrimSuffix(ctx.Params("reponame"), ".git")
+ userName := ctx.PathParam("username")
+ repoName := strings.TrimSuffix(ctx.PathParam("reponame"), ".git")
authorization := ctx.Req.Header.Get("Authorization")
repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, userName, repoName)
@@ -321,7 +321,7 @@ func UnLockHandler(ctx *context.Context) {
return
}
- lock, err := git_model.DeleteLFSLockByID(ctx, ctx.ParamsInt64("lid"), repository, ctx.Doer, req.Force)
+ lock, err := git_model.DeleteLFSLockByID(ctx, ctx.PathParamInt64("lid"), repository, ctx.Doer, req.Force)
if err != nil {
if git_model.IsErrLFSUnauthorizedAction(err) {
ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=gitea-lfs")
@@ -330,7 +330,7 @@ func UnLockHandler(ctx *context.Context) {
})
return
}
- log.Error("Unable to DeleteLFSLockByID[%d] by user %-v with force %t: Error: %v", ctx.ParamsInt64("lid"), ctx.Doer, req.Force, err)
+ log.Error("Unable to DeleteLFSLockByID[%d] by user %-v with force %t: Error: %v", ctx.PathParamInt64("lid"), ctx.Doer, req.Force, err)
ctx.JSON(http.StatusInternalServerError, api.LFSLockError{
Message: "unable to delete lock : Internal Server Error",
})
diff --git a/services/lfs/server.go b/services/lfs/server.go
index ae3dffe0c2..751dac64a0 100644
--- a/services/lfs/server.go
+++ b/services/lfs/server.go
@@ -82,7 +82,7 @@ var rangeHeaderRegexp = regexp.MustCompile(`bytes=(\d+)\-(\d*).*`)
// DownloadHandler gets the content from the content store
func DownloadHandler(ctx *context.Context) {
rc := getRequestContext(ctx)
- p := lfs_module.Pointer{Oid: ctx.Params("oid")}
+ p := lfs_module.Pointer{Oid: ctx.PathParam("oid")}
meta := getAuthenticatedMeta(ctx, rc, p, false)
if meta == nil {
@@ -137,7 +137,7 @@ func DownloadHandler(ctx *context.Context) {
ctx.Resp.Header().Set("Content-Length", strconv.FormatInt(contentLength, 10))
ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
- filename := ctx.Params("filename")
+ filename := ctx.PathParam("filename")
if len(filename) > 0 {
decodedFilename, err := base64.RawURLEncoding.DecodeString(filename)
if err == nil {
@@ -272,9 +272,9 @@ func BatchHandler(ctx *context.Context) {
func UploadHandler(ctx *context.Context) {
rc := getRequestContext(ctx)
- p := lfs_module.Pointer{Oid: ctx.Params("oid")}
+ p := lfs_module.Pointer{Oid: ctx.PathParam("oid")}
var err error
- if p.Size, err = strconv.ParseInt(ctx.Params("size"), 10, 64); err != nil {
+ if p.Size, err = strconv.ParseInt(ctx.PathParam("size"), 10, 64); err != nil {
writeStatusMessage(ctx, http.StatusUnprocessableEntity, err.Error())
}
@@ -384,8 +384,8 @@ func decodeJSON(req *http.Request, v any) error {
func getRequestContext(ctx *context.Context) *requestContext {
return &requestContext{
- User: ctx.Params("username"),
- Repo: strings.TrimSuffix(ctx.Params("reponame"), ".git"),
+ User: ctx.PathParam("username"),
+ Repo: strings.TrimSuffix(ctx.PathParam("reponame"), ".git"),
Authorization: ctx.Req.Header.Get("Authorization"),
}
}
diff --git a/services/repository/files/content_test.go b/services/repository/files/content_test.go
index 4811f9d327..a899be70e3 100644
--- a/services/repository/files/content_test.go
+++ b/services/repository/files/content_test.go
@@ -53,7 +53,7 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse {
func TestGetContents(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -81,7 +81,7 @@ func TestGetContents(t *testing.T) {
func TestGetContentsOrListForDir(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -116,7 +116,7 @@ func TestGetContentsOrListForDir(t *testing.T) {
func TestGetContentsOrListForFile(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -144,7 +144,7 @@ func TestGetContentsOrListForFile(t *testing.T) {
func TestGetContentsErrors(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -175,7 +175,7 @@ func TestGetContentsErrors(t *testing.T) {
func TestGetContentsOrListErrors(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -206,7 +206,7 @@ func TestGetContentsOrListErrors(t *testing.T) {
func TestGetContentsOrListOfEmptyRepos(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user30/empty")
- ctx.SetParams(":id", "52")
+ ctx.SetPathParam(":id", "52")
contexttest.LoadRepo(t, ctx, 52)
contexttest.LoadUser(t, ctx, 30)
contexttest.LoadGitRepo(t, ctx)
@@ -231,15 +231,15 @@ func TestGetBlobBySHA(t *testing.T) {
defer ctx.Repo.GitRepo.Close()
sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d"
- ctx.SetParams(":id", "1")
- ctx.SetParams(":sha", sha)
+ ctx.SetPathParam(":id", "1")
+ ctx.SetPathParam(":sha", sha)
gitRepo, err := gitrepo.OpenRepository(ctx, ctx.Repo.Repository)
if err != nil {
t.Fail()
}
- gbr, err := GetBlobBySHA(ctx, ctx.Repo.Repository, gitRepo, ctx.Params(":sha"))
+ gbr, err := GetBlobBySHA(ctx, ctx.Repo.Repository, gitRepo, ctx.PathParam(":sha"))
expectedGBR := &api.GitBlobResponse{
Content: "dHJlZSAyYTJmMWQ0NjcwNzI4YTJlMTAwNDllMzQ1YmQ3YTI3NjQ2OGJlYWI2CmF1dGhvciB1c2VyMSA8YWRkcmVzczFAZXhhbXBsZS5jb20+IDE0ODk5NTY0NzkgLTA0MDAKY29tbWl0dGVyIEV0aGFuIEtvZW5pZyA8ZXRoYW50a29lbmlnQGdtYWlsLmNvbT4gMTQ4OTk1NjQ3OSAtMDQwMAoKSW5pdGlhbCBjb21taXQK",
Encoding: "base64",
diff --git a/services/repository/files/diff_test.go b/services/repository/files/diff_test.go
index 63aff9b0e3..ea6ffe60c3 100644
--- a/services/repository/files/diff_test.go
+++ b/services/repository/files/diff_test.go
@@ -18,7 +18,7 @@ import (
func TestGetDiffPreview(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -140,7 +140,7 @@ func TestGetDiffPreview(t *testing.T) {
func TestGetDiffPreviewErrors(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
diff --git a/services/repository/files/file_test.go b/services/repository/files/file_test.go
index a5b3aad91e..b2f51e3c82 100644
--- a/services/repository/files/file_test.go
+++ b/services/repository/files/file_test.go
@@ -99,7 +99,7 @@ func getExpectedFileResponse() *api.FileResponse {
func TestGetFileResponseFromCommit(t *testing.T) {
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
diff --git a/services/repository/files/tree_test.go b/services/repository/files/tree_test.go
index 508f20090d..786bc15857 100644
--- a/services/repository/files/tree_test.go
+++ b/services/repository/files/tree_test.go
@@ -25,10 +25,10 @@ func TestGetTreeBySHA(t *testing.T) {
sha := ctx.Repo.Repository.DefaultBranch
page := 1
perPage := 10
- ctx.SetParams(":id", "1")
- ctx.SetParams(":sha", sha)
+ ctx.SetPathParam(":id", "1")
+ ctx.SetPathParam(":sha", sha)
- tree, err := GetTreeBySHA(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Params(":sha"), page, perPage, true)
+ tree, err := GetTreeBySHA(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.PathParam(":sha"), page, perPage, true)
assert.NoError(t, err)
expectedTree := &api.GitTreeResponse{
SHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
diff --git a/services/wiki/wiki_path.go b/services/wiki/wiki_path.go
index 74c7064043..212a35ea25 100644
--- a/services/wiki/wiki_path.go
+++ b/services/wiki/wiki_path.go
@@ -33,7 +33,7 @@ import (
// TODO: support subdirectory in the future
//
// Although this package now has the ability to support subdirectory, but the route package doesn't:
-// * Double-escaping problem: the URL "/wiki/abc%2Fdef" becomes "/wiki/abc/def" by ctx.Params, which is incorrect
+// * Double-escaping problem: the URL "/wiki/abc%2Fdef" becomes "/wiki/abc/def" by ctx.PathParam, which is incorrect
// * This problem should have been 99% fixed, but it needs more tests.
// * The old wiki code's behavior is always using %2F, instead of subdirectory, so there are a lot of legacy "%2F" files in user wikis.
diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go
index c8a792d6a3..60528a1a78 100644
--- a/tests/e2e/e2e_test.go
+++ b/tests/e2e/e2e_test.go
@@ -28,7 +28,7 @@ import (
"code.gitea.io/gitea/tests"
)
-var testE2eWebRoutes *web.Route
+var testE2eWebRoutes *web.Router
func TestMain(m *testing.M) {
defer log.GetManager().Close()
diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go
index 18f415083c..ae8ff51d43 100644
--- a/tests/integration/integration_test.go
+++ b/tests/integration/integration_test.go
@@ -40,7 +40,7 @@ import (
"github.com/xeipuuv/gojsonschema"
)
-var testWebRoutes *web.Route
+var testWebRoutes *web.Router
type NilResponseRecorder struct {
httptest.ResponseRecorder
diff --git a/tests/integration/repofiles_change_test.go b/tests/integration/repofiles_change_test.go
index 7633d6915f..9f938c4099 100644
--- a/tests/integration/repofiles_change_test.go
+++ b/tests/integration/repofiles_change_test.go
@@ -247,7 +247,7 @@ func TestChangeRepoFilesForCreate(t *testing.T) {
// setup
onGiteaRun(t, func(t *testing.T, u *url.URL) {
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -284,7 +284,7 @@ func TestChangeRepoFilesForUpdate(t *testing.T) {
// setup
onGiteaRun(t, func(t *testing.T, u *url.URL) {
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -318,7 +318,7 @@ func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) {
// setup
onGiteaRun(t, func(t *testing.T, u *url.URL) {
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -369,7 +369,7 @@ func TestChangeRepoFilesWithoutBranchNames(t *testing.T) {
// setup
onGiteaRun(t, func(t *testing.T, u *url.URL) {
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -405,7 +405,7 @@ func testDeleteRepoFiles(t *testing.T, u *url.URL) {
// setup
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -444,7 +444,7 @@ func testDeleteRepoFilesWithoutBranchNames(t *testing.T, u *url.URL) {
// setup
unittest.PrepareTestEnv(t)
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)
@@ -474,7 +474,7 @@ func TestChangeRepoFilesErrors(t *testing.T) {
// setup
onGiteaRun(t, func(t *testing.T, u *url.URL) {
ctx, _ := contexttest.MockContext(t, "user2/repo1")
- ctx.SetParams(":id", "1")
+ ctx.SetPathParam(":id", "1")
contexttest.LoadRepo(t, ctx, 1)
contexttest.LoadRepoCommit(t, ctx)
contexttest.LoadUser(t, ctx, 2)