diff options
Diffstat (limited to 'routers/api/packages/swift/swift.go')
-rw-r--r-- | routers/api/packages/swift/swift.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/routers/api/packages/swift/swift.go b/routers/api/packages/swift/swift.go index 47439c4c3b..e1c3b36834 100644 --- a/routers/api/packages/swift/swift.go +++ b/routers/api/packages/swift/swift.go @@ -77,17 +77,14 @@ func apiError(ctx *context.Context, status int, obj any) { Detail string `json:"detail"` } - helper.LogAndProcessError(ctx, status, obj, func(message string) { - setResponseHeaders(ctx.Resp, &headers{ - Status: status, - ContentType: "application/problem+json", - }) - if err := json.NewEncoder(ctx.Resp).Encode(Problem{ - Status: status, - Detail: message, - }); err != nil { - log.Error("JSON encode: %v", err) - } + message := helper.ProcessErrorForUser(ctx, status, obj) + setResponseHeaders(ctx.Resp, &headers{ + Status: status, + ContentType: "application/problem+json", + }) + _ = json.NewEncoder(ctx.Resp).Encode(Problem{ + Status: status, + Detail: message, }) } @@ -429,7 +426,7 @@ func DownloadPackageFile(ctx *context.Context) { pf := pd.Files[0].File - s, u, _, err := packages_service.GetPackageFileStream(ctx, pf) + s, u, _, err := packages_service.OpenFileForDownload(ctx, pf, ctx.Req.Method) if err != nil { apiError(ctx, http.StatusInternalServerError, err) return |