1
0
Fork 0
forked from forgejo/forgejo

[refactor] replace int with httpStatusCodes (#15282)

* replace "200" (int) with "http.StatusOK" (const)

* ctx.Error & ctx.HTML

* ctx.JSON Part1

* ctx.JSON Part2

* ctx.JSON Part3
This commit is contained in:
6543 2021-04-05 17:30:52 +02:00 committed by GitHub
parent e9fba18a26
commit 16dea6cebd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 504 additions and 441 deletions

View file

@ -203,12 +203,12 @@ func (ctx *APIContext) CheckForOTP() {
if models.IsErrTwoFactorNotEnrolled(err) {
return // No 2FA enrollment for this user
}
ctx.Context.Error(500)
ctx.Context.Error(http.StatusInternalServerError)
return
}
ok, err := twofa.ValidateTOTP(otpHeader)
if err != nil {
ctx.Context.Error(500)
ctx.Context.Error(http.StatusInternalServerError)
return
}
if !ok {
@ -288,7 +288,7 @@ func ReferencesGitRepo(allowEmpty bool) func(http.Handler) http.Handler {
repoPath := models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
gitRepo, err := git.OpenRepository(repoPath)
if err != nil {
ctx.Error(500, "RepoRef Invalid repo "+repoPath, err)
ctx.Error(http.StatusInternalServerError, "RepoRef Invalid repo "+repoPath, err)
return
}
ctx.Repo.GitRepo = gitRepo
@ -324,7 +324,7 @@ func (ctx *APIContext) NotFound(objs ...interface{}) {
}
}
ctx.JSON(404, map[string]interface{}{
ctx.JSON(http.StatusNotFound, map[string]interface{}{
"message": message,
"documentation_url": setting.API.SwaggerURL,
"errors": errors,