mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
Small refactoring of modules/private (#15947)
* Use correct variable name. * doer is never nil here. * Use status code constants. * Replaced generic map with concrete struct. * Fixed windows lint. * Removed unused method. * Changed error codes. Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
@@ -6,9 +6,11 @@ package private
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
myCtx "code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/migrations"
|
||||
"code.gitea.io/gitea/modules/private"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
@@ -17,8 +19,8 @@ func RestoreRepo(ctx *myCtx.PrivateContext) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
bs, err := ioutil.ReadAll(ctx.Req.Body)
|
||||
if err != nil {
|
||||
ctx.JSON(500, map[string]string{
|
||||
"err": err.Error(),
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
Err: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -29,8 +31,8 @@ func RestoreRepo(ctx *myCtx.PrivateContext) {
|
||||
Units []string
|
||||
}{}
|
||||
if err = json.Unmarshal(bs, ¶ms); err != nil {
|
||||
ctx.JSON(500, map[string]string{
|
||||
"err": err.Error(),
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
Err: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -42,10 +44,10 @@ func RestoreRepo(ctx *myCtx.PrivateContext) {
|
||||
params.RepoName,
|
||||
params.Units,
|
||||
); err != nil {
|
||||
ctx.JSON(500, map[string]string{
|
||||
"err": err.Error(),
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
Err: err.Error(),
|
||||
})
|
||||
} else {
|
||||
ctx.Status(200)
|
||||
ctx.Status(http.StatusOK)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user