[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

@ -6,6 +6,7 @@ package setting
import (
"fmt"
"net/http"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
@ -29,7 +30,7 @@ func OAuthApplicationsPost(ctx *context.Context) {
if ctx.HasError() {
loadApplicationsData(ctx)
ctx.HTML(200, tplSettingsApplications)
ctx.HTML(http.StatusOK, tplSettingsApplications)
return
}
// TODO validate redirect URI
@ -49,7 +50,7 @@ func OAuthApplicationsPost(ctx *context.Context) {
ctx.ServerError("GenerateClientSecret", err)
return
}
ctx.HTML(200, tplSettingsOAuthApplications)
ctx.HTML(http.StatusOK, tplSettingsOAuthApplications)
}
// OAuthApplicationsEdit response for editing oauth2 application
@ -61,7 +62,7 @@ func OAuthApplicationsEdit(ctx *context.Context) {
if ctx.HasError() {
loadApplicationsData(ctx)
ctx.HTML(200, tplSettingsApplications)
ctx.HTML(http.StatusOK, tplSettingsApplications)
return
}
// TODO validate redirect URI
@ -76,7 +77,7 @@ func OAuthApplicationsEdit(ctx *context.Context) {
return
}
ctx.Flash.Success(ctx.Tr("settings.update_oauth2_application_success"))
ctx.HTML(200, tplSettingsOAuthApplications)
ctx.HTML(http.StatusOK, tplSettingsOAuthApplications)
}
// OAuthApplicationsRegenerateSecret handles the post request for regenerating the secret
@ -104,7 +105,7 @@ func OAuthApplicationsRegenerateSecret(ctx *context.Context) {
return
}
ctx.Flash.Success(ctx.Tr("settings.update_oauth2_application_success"))
ctx.HTML(200, tplSettingsOAuthApplications)
ctx.HTML(http.StatusOK, tplSettingsOAuthApplications)
}
// OAuth2ApplicationShow displays the given application
@ -123,7 +124,7 @@ func OAuth2ApplicationShow(ctx *context.Context) {
return
}
ctx.Data["App"] = app
ctx.HTML(200, tplSettingsOAuthApplications)
ctx.HTML(http.StatusOK, tplSettingsOAuthApplications)
}
// DeleteOAuth2Application deletes the given oauth2 application
@ -135,7 +136,7 @@ func DeleteOAuth2Application(ctx *context.Context) {
log.Trace("OAuth2 Application deleted: %s", ctx.User.Name)
ctx.Flash.Success(ctx.Tr("settings.remove_oauth2_application_success"))
ctx.JSON(200, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]interface{}{
"redirect": setting.AppSubURL + "/user/settings/applications",
})
}
@ -152,7 +153,7 @@ func RevokeOAuth2Grant(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("settings.revoke_oauth2_grant_success"))
ctx.JSON(200, map[string]interface{}{
ctx.JSON(http.StatusOK, map[string]interface{}{
"redirect": setting.AppSubURL + "/user/settings/applications",
})
}