summaryrefslogtreecommitdiffstats
path: root/routers/repo/attachment.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/repo/attachment.go')
-rw-r--r--routers/repo/attachment.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go
index 5df9cdbf12..a896e4a501 100644
--- a/routers/repo/attachment.go
+++ b/routers/repo/attachment.go
@@ -29,13 +29,13 @@ func UploadReleaseAttachment(ctx *context.Context) {
// UploadAttachment response for uploading attachments
func uploadAttachment(ctx *context.Context, allowedTypes string) {
if !setting.Attachment.Enabled {
- ctx.Error(404, "attachment is not enabled")
+ ctx.Error(http.StatusNotFound, "attachment is not enabled")
return
}
file, header, err := ctx.Req.FormFile("file")
if err != nil {
- ctx.Error(500, fmt.Sprintf("FormFile: %v", err))
+ ctx.Error(http.StatusInternalServerError, fmt.Sprintf("FormFile: %v", err))
return
}
defer file.Close()
@@ -48,7 +48,7 @@ func uploadAttachment(ctx *context.Context, allowedTypes string) {
err = upload.Verify(buf, header.Filename, allowedTypes)
if err != nil {
- ctx.Error(400, err.Error())
+ ctx.Error(http.StatusBadRequest, err.Error())
return
}
@@ -57,12 +57,12 @@ func uploadAttachment(ctx *context.Context, allowedTypes string) {
Name: header.Filename,
}, buf, file)
if err != nil {
- ctx.Error(500, fmt.Sprintf("NewAttachment: %v", err))
+ ctx.Error(http.StatusInternalServerError, fmt.Sprintf("NewAttachment: %v", err))
return
}
log.Trace("New attachment uploaded: %s", attach.UUID)
- ctx.JSON(200, map[string]string{
+ ctx.JSON(http.StatusOK, map[string]string{
"uuid": attach.UUID,
})
}
@@ -72,19 +72,19 @@ func DeleteAttachment(ctx *context.Context) {
file := ctx.Query("file")
attach, err := models.GetAttachmentByUUID(file)
if err != nil {
- ctx.Error(400, err.Error())
+ ctx.Error(http.StatusBadRequest, err.Error())
return
}
if !ctx.IsSigned || (ctx.User.ID != attach.UploaderID) {
- ctx.Error(403)
+ ctx.Error(http.StatusForbidden)
return
}
err = models.DeleteAttachment(attach, true)
if err != nil {
- ctx.Error(500, fmt.Sprintf("DeleteAttachment: %v", err))
+ ctx.Error(http.StatusInternalServerError, fmt.Sprintf("DeleteAttachment: %v", err))
return
}
- ctx.JSON(200, map[string]string{
+ ctx.JSON(http.StatusOK, map[string]string{
"uuid": attach.UUID,
})
}
@@ -94,7 +94,7 @@ func GetAttachment(ctx *context.Context) {
attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid"))
if err != nil {
if models.IsErrAttachmentNotExist(err) {
- ctx.Error(404)
+ ctx.Error(http.StatusNotFound)
} else {
ctx.ServerError("GetAttachmentByUUID", err)
}