mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Updates to API 404 responses (#6077)
This commit is contained in:
committed by
techknowlogick
parent
d10a668ffc
commit
cac9e6e760
@@ -112,7 +112,7 @@ func DeleteAccessToken(ctx *context.APIContext) {
|
||||
tokenID := ctx.ParamsInt64(":id")
|
||||
if err := models.DeleteAccessTokenByID(tokenID, ctx.User.ID); err != nil {
|
||||
if models.IsErrAccessTokenNotExist(err) {
|
||||
ctx.Status(404)
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(500, "DeleteAccessTokenByID", err)
|
||||
}
|
||||
|
@@ -113,7 +113,7 @@ func checkUserFollowing(ctx *context.APIContext, u *models.User, followID int64)
|
||||
if u.IsFollowing(followID) {
|
||||
ctx.Status(204)
|
||||
} else {
|
||||
ctx.Status(404)
|
||||
ctx.NotFound()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -90,7 +90,7 @@ func GetGPGKey(ctx *context.APIContext) {
|
||||
key, err := models.GetGPGKeyByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if models.IsErrGPGKeyNotExist(err) {
|
||||
ctx.Status(404)
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(500, "GetGPGKeyByID", err)
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ func GetUserByParamsName(ctx *context.APIContext, name string) *models.User {
|
||||
user, err := models.GetUserByName(ctx.Params(name))
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
ctx.Status(404)
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(500, "GetUserByName", err)
|
||||
}
|
||||
@@ -165,7 +165,7 @@ func GetPublicKey(ctx *context.APIContext) {
|
||||
key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if models.IsErrKeyNotExist(err) {
|
||||
ctx.Status(404)
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(500, "GetPublicKeyByID", err)
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func DeletePublicKey(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/notFound"
|
||||
if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
||||
if models.IsErrKeyNotExist(err) {
|
||||
ctx.Status(404)
|
||||
ctx.NotFound()
|
||||
} else if models.IsErrKeyAccessDenied(err) {
|
||||
ctx.Error(403, "", "You do not have access to this key")
|
||||
} else {
|
||||
|
@@ -96,7 +96,7 @@ func IsStarring(ctx *context.APIContext) {
|
||||
if models.IsStaring(ctx.User.ID, ctx.Repo.Repository.ID) {
|
||||
ctx.Status(204)
|
||||
} else {
|
||||
ctx.Status(404)
|
||||
ctx.NotFound()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -109,7 +109,7 @@ func GetInfo(ctx *context.APIContext) {
|
||||
u, err := models.GetUserByName(ctx.Params(":username"))
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
ctx.Status(404)
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(500, "GetUserByName", err)
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ func IsWatching(ctx *context.APIContext) {
|
||||
RepositoryURL: repositoryURL(ctx.Repo.Repository),
|
||||
})
|
||||
} else {
|
||||
ctx.Status(404)
|
||||
ctx.NotFound()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user