mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-09 03:45:22 +02:00
Refactor HTTP request context (#17979)
This commit is contained in:
parent
9d943bf374
commit
4da1d97810
26 changed files with 139 additions and 177 deletions
|
@ -71,5 +71,5 @@ func SetDefaultBranch(ctx *gitea_context.PrivateContext) {
|
|||
})
|
||||
return
|
||||
}
|
||||
ctx.PlainText(http.StatusOK, []byte("success"))
|
||||
ctx.PlainText(http.StatusOK, "success")
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue