summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/admin
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-13 18:49:16 -0400
committerUnknwon <u@gogs.io>2016-03-13 18:49:16 -0400
commitdd6faf7f9bd0a1dbf986e124ea0f4db249e1da48 (patch)
tree7f9e4107eb961712a56160ef544143eee3771653 /routers/api/v1/admin
parentdb4da7beecd6a8f65bfa264ba18a8cb12303921f (diff)
downloadgitea-dd6faf7f9bd0a1dbf986e124ea0f4db249e1da48.tar.gz
gitea-dd6faf7f9bd0a1dbf986e124ea0f4db249e1da48.zip
Convert all API handers to use *context.APIContext
Diffstat (limited to 'routers/api/v1/admin')
-rw-r--r--routers/api/v1/admin/orgs.go6
-rw-r--r--routers/api/v1/admin/repos.go2
-rw-r--r--routers/api/v1/admin/users.go28
3 files changed, 18 insertions, 18 deletions
diff --git a/routers/api/v1/admin/orgs.go b/routers/api/v1/admin/orgs.go
index f212c4f517..1e7ad15657 100644
--- a/routers/api/v1/admin/orgs.go
+++ b/routers/api/v1/admin/orgs.go
@@ -14,7 +14,7 @@ import (
)
// https://github.com/gogits/go-gogs-client/wiki/Administration-Organizations#create-a-new-organization
-func CreateOrg(ctx *context.Context, form api.CreateOrgOption) {
+func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) {
u := user.GetUserByParams(ctx)
if ctx.Written() {
return
@@ -33,9 +33,9 @@ func CreateOrg(ctx *context.Context, form api.CreateOrgOption) {
if models.IsErrUserAlreadyExist(err) ||
models.IsErrNameReserved(err) ||
models.IsErrNamePatternNotAllowed(err) {
- ctx.APIError(422, "CreateOrganization", err)
+ ctx.Error(422, "CreateOrganization", err)
} else {
- ctx.APIError(500, "CreateOrganization", err)
+ ctx.Error(500, "CreateOrganization", err)
}
return
}
diff --git a/routers/api/v1/admin/repos.go b/routers/api/v1/admin/repos.go
index 27f46c51c5..0f0c3862de 100644
--- a/routers/api/v1/admin/repos.go
+++ b/routers/api/v1/admin/repos.go
@@ -13,7 +13,7 @@ import (
)
// https://github.com/gogits/go-gogs-client/wiki/Administration-Repositories#create-a-new-repository
-func CreateRepo(ctx *context.Context, form api.CreateRepoOption) {
+func CreateRepo(ctx *context.APIContext, form api.CreateRepoOption) {
owner := user.GetUserByParams(ctx)
if ctx.Written() {
return
diff --git a/routers/api/v1/admin/users.go b/routers/api/v1/admin/users.go
index f0a6c293e5..50409cff94 100644
--- a/routers/api/v1/admin/users.go
+++ b/routers/api/v1/admin/users.go
@@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/routers/api/v1/user"
)
-func parseLoginSource(ctx *context.Context, u *models.User, sourceID int64, loginName string) {
+func parseLoginSource(ctx *context.APIContext, u *models.User, sourceID int64, loginName string) {
if sourceID == 0 {
return
}
@@ -24,9 +24,9 @@ func parseLoginSource(ctx *context.Context, u *models.User, sourceID int64, logi
source, err := models.GetLoginSourceByID(sourceID)
if err != nil {
if models.IsErrAuthenticationNotExist(err) {
- ctx.APIError(422, "", err)
+ ctx.Error(422, "", err)
} else {
- ctx.APIError(500, "GetLoginSourceByID", err)
+ ctx.Error(500, "GetLoginSourceByID", err)
}
return
}
@@ -37,7 +37,7 @@ func parseLoginSource(ctx *context.Context, u *models.User, sourceID int64, logi
}
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-new-user
-func CreateUser(ctx *context.Context, form api.CreateUserOption) {
+func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
u := &models.User{
Name: form.Username,
Email: form.Email,
@@ -56,9 +56,9 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) {
models.IsErrEmailAlreadyUsed(err) ||
models.IsErrNameReserved(err) ||
models.IsErrNamePatternNotAllowed(err) {
- ctx.APIError(422, "", err)
+ ctx.Error(422, "", err)
} else {
- ctx.APIError(500, "CreateUser", err)
+ ctx.Error(500, "CreateUser", err)
}
return
}
@@ -66,14 +66,14 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) {
// Send e-mail notification.
if form.SendNotify && setting.MailService != nil {
- mailer.SendRegisterNotifyMail(ctx.Context, u)
+ mailer.SendRegisterNotifyMail(ctx.Context.Context, u)
}
ctx.JSON(201, convert.ToApiUser(u))
}
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#edit-an-existing-user
-func EditUser(ctx *context.Context, form api.EditUserOption) {
+func EditUser(ctx *context.APIContext, form api.EditUserOption) {
u := user.GetUserByParams(ctx)
if ctx.Written() {
return
@@ -110,9 +110,9 @@ func EditUser(ctx *context.Context, form api.EditUserOption) {
if err := models.UpdateUser(u); err != nil {
if models.IsErrEmailAlreadyUsed(err) {
- ctx.APIError(422, "", err)
+ ctx.Error(422, "", err)
} else {
- ctx.APIError(500, "UpdateUser", err)
+ ctx.Error(500, "UpdateUser", err)
}
return
}
@@ -122,7 +122,7 @@ func EditUser(ctx *context.Context, form api.EditUserOption) {
}
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#delete-a-user
-func DeleteUser(ctx *context.Context) {
+func DeleteUser(ctx *context.APIContext) {
u := user.GetUserByParams(ctx)
if ctx.Written() {
return
@@ -131,9 +131,9 @@ func DeleteUser(ctx *context.Context) {
if err := models.DeleteUser(u); err != nil {
if models.IsErrUserOwnRepos(err) ||
models.IsErrUserHasOrgs(err) {
- ctx.APIError(422, "", err)
+ ctx.Error(422, "", err)
} else {
- ctx.APIError(500, "DeleteUser", err)
+ ctx.Error(500, "DeleteUser", err)
}
return
}
@@ -143,7 +143,7 @@ func DeleteUser(ctx *context.Context) {
}
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-public-key-for-user
-func CreatePublicKey(ctx *context.Context, form api.CreateKeyOption) {
+func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
u := user.GetUserByParams(ctx)
if ctx.Written() {
return