diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2021-06-23 21:38:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 15:38:19 -0400 |
commit | 383ffcfa34d284e3938517989a036da31ad42215 (patch) | |
tree | de70721e8cafa239a4a6bf8585f4cbce56504621 /routers/private/restore_repo.go | |
parent | 5930d09096b6ab8d55aabf490ed4ea27faa7f17f (diff) | |
download | gitea-383ffcfa34d284e3938517989a036da31ad42215.tar.gz gitea-383ffcfa34d284e3938517989a036da31ad42215.zip |
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>
Diffstat (limited to 'routers/private/restore_repo.go')
-rw-r--r-- | routers/private/restore_repo.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/routers/private/restore_repo.go b/routers/private/restore_repo.go index df787e1b33..36d17dd95c 100644 --- a/routers/private/restore_repo.go +++ b/routers/private/restore_repo.go @@ -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) } } |