aboutsummaryrefslogtreecommitdiffstats
path: root/routers/private
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-06-19 06:32:45 +0800
committerGitHub <noreply@github.com>2024-06-19 06:32:45 +0800
commit43c7a2e7b1c7fb8aa2347d82ad0a6886d6fad9c2 (patch)
treec98c2e1159ee02eb52282811f28a4c31ad222c67 /routers/private
parent17baf1af10de025a47ade1f16f1e5c51646d7fcf (diff)
downloadgitea-43c7a2e7b1c7fb8aa2347d82ad0a6886d6fad9c2.tar.gz
gitea-43c7a2e7b1c7fb8aa2347d82ad0a6886d6fad9c2.zip
Refactor names (#31405)
This PR only does "renaming": * `Route` should be `Router` (and chi router is also called "router") * `Params` should be `PathParam` (to distingush it from URL query param, and to match `FormString`) * Use lower case for private functions to avoid exposing or abusing
Diffstat (limited to 'routers/private')
-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
7 files changed, 17 insertions, 17 deletions
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