diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-12-15 14:59:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-15 14:59:57 +0800 |
commit | 4da1d9781025aa4a85899b1ddeb25aabbaa82703 (patch) | |
tree | 9714f71f2fb042e44d418fbcfc56cd8440a1bbb1 /routers/private | |
parent | 9d943bf374e56e4d403303a6a2caafc1c79cdb6f (diff) | |
download | gitea-4da1d9781025aa4a85899b1ddeb25aabbaa82703.tar.gz gitea-4da1d9781025aa4a85899b1ddeb25aabbaa82703.zip |
Refactor HTTP request context (#17979)
Diffstat (limited to 'routers/private')
-rw-r--r-- | routers/private/default_branch.go | 2 | ||||
-rw-r--r-- | routers/private/hook_pre_receive.go | 2 | ||||
-rw-r--r-- | routers/private/key.go | 6 | ||||
-rw-r--r-- | routers/private/mail.go | 2 | ||||
-rw-r--r-- | routers/private/manager.go | 12 | ||||
-rw-r--r-- | routers/private/manager_unix.go | 4 | ||||
-rw-r--r-- | routers/private/manager_windows.go | 2 |
7 files changed, 15 insertions, 15 deletions
diff --git a/routers/private/default_branch.go b/routers/private/default_branch.go index 974534c219..5fdd0df735 100644 --- a/routers/private/default_branch.go +++ b/routers/private/default_branch.go @@ -71,5 +71,5 @@ func SetDefaultBranch(ctx *gitea_context.PrivateContext) { }) return } - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go index 17ccf010ae..7ad719155c 100644 --- a/routers/private/hook_pre_receive.go +++ b/routers/private/hook_pre_receive.go @@ -134,7 +134,7 @@ func HookPreReceive(ctx *gitea_context.PrivateContext) { } } - ctx.PlainText(http.StatusOK, []byte("ok")) + ctx.PlainText(http.StatusOK, "ok") } func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID, refFullName string) { diff --git a/routers/private/key.go b/routers/private/key.go index 30fde73c8a..3366b764e6 100644 --- a/routers/private/key.go +++ b/routers/private/key.go @@ -28,7 +28,7 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) { deployKey, err := asymkey_model.GetDeployKeyByRepo(keyID, repoID) if err != nil { if asymkey_model.IsErrDeployKeyNotExist(err) { - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") return } ctx.JSON(http.StatusInternalServerError, private.Response{ @@ -44,7 +44,7 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) { return } - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } // AuthorizedPublicKeyByContent searches content as prefix (leak e-mail part) @@ -59,5 +59,5 @@ func AuthorizedPublicKeyByContent(ctx *context.PrivateContext) { }) return } - ctx.PlainText(http.StatusOK, []byte(publicKey.AuthorizedString())) + ctx.PlainText(http.StatusOK, publicKey.AuthorizedString()) } diff --git a/routers/private/mail.go b/routers/private/mail.go index 5218cd34a1..8b69c38093 100644 --- a/routers/private/mail.go +++ b/routers/private/mail.go @@ -86,5 +86,5 @@ func sendEmail(ctx *context.PrivateContext, subject, message string, to []string wasSent := strconv.Itoa(len(to)) - ctx.PlainText(http.StatusOK, []byte(wasSent)) + ctx.PlainText(http.StatusOK, wasSent) } diff --git a/routers/private/manager.go b/routers/private/manager.go index 2b4cfb8ef4..a3b9a16f79 100644 --- a/routers/private/manager.go +++ b/routers/private/manager.go @@ -41,19 +41,19 @@ func FlushQueues(ctx *context.PrivateContext) { Err: fmt.Sprintf("%v", err), }) } - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } // PauseLogging pauses logging func PauseLogging(ctx *context.PrivateContext) { log.Pause() - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } // ResumeLogging resumes logging func ResumeLogging(ctx *context.PrivateContext) { log.Resume() - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } // ReleaseReopenLogging releases and reopens logging files @@ -64,7 +64,7 @@ func ReleaseReopenLogging(ctx *context.PrivateContext) { }) return } - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } // RemoveLogger removes a logger @@ -81,7 +81,7 @@ func RemoveLogger(ctx *context.PrivateContext) { if ok { setting.RemoveSubLogDescription(group, name) } - ctx.PlainText(http.StatusOK, []byte(fmt.Sprintf("Removed %s %s", group, name))) + ctx.PlainText(http.StatusOK, fmt.Sprintf("Removed %s %s", group, name)) } // AddLogger adds a logger @@ -154,5 +154,5 @@ func AddLogger(ctx *context.PrivateContext) { Config: config, }) - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } diff --git a/routers/private/manager_unix.go b/routers/private/manager_unix.go index 1738c06a05..f00f202207 100644 --- a/routers/private/manager_unix.go +++ b/routers/private/manager_unix.go @@ -17,12 +17,12 @@ import ( // Restart causes the server to perform a graceful restart func Restart(ctx *context.PrivateContext) { graceful.GetManager().DoGracefulRestart() - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } // Shutdown causes the server to perform a graceful shutdown func Shutdown(ctx *context.PrivateContext) { graceful.GetManager().DoGracefulShutdown() - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } diff --git a/routers/private/manager_windows.go b/routers/private/manager_windows.go index a8a477313f..014018a539 100644 --- a/routers/private/manager_windows.go +++ b/routers/private/manager_windows.go @@ -25,5 +25,5 @@ func Restart(ctx *context.PrivateContext) { // Shutdown causes the server to perform a graceful shutdown func Shutdown(ctx *context.PrivateContext) { graceful.GetManager().DoGracefulShutdown() - ctx.PlainText(http.StatusOK, []byte("success")) + ctx.PlainText(http.StatusOK, "success") } |