diff options
author | Unknwon <u@gogs.io> | 2016-03-11 11:56:52 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-03-11 11:56:52 -0500 |
commit | 514382e2ebfe6869268aeb919c1fa4d224687e13 (patch) | |
tree | 1aa8c4b3b1e771a5dc6f0bdd74567961570efcaa /routers/api/v1/user | |
parent | cb1eadc2768ea5ffb2967eb4262e96730c3f9ba5 (diff) | |
download | gitea-514382e2ebfe6869268aeb919c1fa4d224687e13.tar.gz gitea-514382e2ebfe6869268aeb919c1fa4d224687e13.zip |
Rename module: middleware -> context
Diffstat (limited to 'routers/api/v1/user')
-rw-r--r-- | routers/api/v1/user/app.go | 6 | ||||
-rw-r--r-- | routers/api/v1/user/email.go | 8 | ||||
-rw-r--r-- | routers/api/v1/user/followers.go | 26 | ||||
-rw-r--r-- | routers/api/v1/user/keys.go | 20 | ||||
-rw-r--r-- | routers/api/v1/user/user.go | 6 |
5 files changed, 33 insertions, 33 deletions
diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index 00aacbdc1b..87413becf0 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -8,11 +8,11 @@ import ( api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models" - "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/context" ) // https://github.com/gogits/go-gogs-client/wiki/Users#list-access-tokens-for-a-user -func ListAccessTokens(ctx *middleware.Context) { +func ListAccessTokens(ctx *context.Context) { tokens, err := models.ListAccessTokens(ctx.User.Id) if err != nil { ctx.APIError(500, "ListAccessTokens", err) @@ -27,7 +27,7 @@ func ListAccessTokens(ctx *middleware.Context) { } // https://github.com/gogits/go-gogs-client/wiki/Users#create-a-access-token -func CreateAccessToken(ctx *middleware.Context, form api.CreateAccessTokenOption) { +func CreateAccessToken(ctx *context.Context, form api.CreateAccessTokenOption) { t := &models.AccessToken{ UID: ctx.User.Id, Name: form.Name, diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go index fd9193bd74..66bddd24cf 100644 --- a/routers/api/v1/user/email.go +++ b/routers/api/v1/user/email.go @@ -8,13 +8,13 @@ import ( api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models" - "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/routers/api/v1/convert" ) // https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user -func ListEmails(ctx *middleware.Context) { +func ListEmails(ctx *context.Context) { emails, err := models.GetEmailAddresses(ctx.User.Id) if err != nil { ctx.Handle(500, "GetEmailAddresses", err) @@ -28,7 +28,7 @@ func ListEmails(ctx *middleware.Context) { } // https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses -func AddEmail(ctx *middleware.Context, form api.CreateEmailOption) { +func AddEmail(ctx *context.Context, form api.CreateEmailOption) { if len(form.Emails) == 0 { ctx.Status(422) return @@ -60,7 +60,7 @@ func AddEmail(ctx *middleware.Context, form api.CreateEmailOption) { } // https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses -func DeleteEmail(ctx *middleware.Context, form api.CreateEmailOption) { +func DeleteEmail(ctx *context.Context, form api.CreateEmailOption) { if len(form.Emails) == 0 { ctx.Status(204) return diff --git a/routers/api/v1/user/followers.go b/routers/api/v1/user/followers.go index 0a28979647..b7166abb3e 100644 --- a/routers/api/v1/user/followers.go +++ b/routers/api/v1/user/followers.go @@ -8,11 +8,11 @@ import ( api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models" - "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/routers/api/v1/convert" ) -func responseApiUsers(ctx *middleware.Context, users []*models.User) { +func responseApiUsers(ctx *context.Context, users []*models.User) { apiUsers := make([]*api.User, len(users)) for i := range users { apiUsers[i] = convert.ToApiUser(users[i]) @@ -20,7 +20,7 @@ func responseApiUsers(ctx *middleware.Context, users []*models.User) { ctx.JSON(200, &apiUsers) } -func listUserFollowers(ctx *middleware.Context, u *models.User) { +func listUserFollowers(ctx *context.Context, u *models.User) { users, err := u.GetFollowers(ctx.QueryInt("page")) if err != nil { ctx.APIError(500, "GetUserFollowers", err) @@ -29,12 +29,12 @@ func listUserFollowers(ctx *middleware.Context, u *models.User) { responseApiUsers(ctx, users) } -func ListMyFollowers(ctx *middleware.Context) { +func ListMyFollowers(ctx *context.Context) { listUserFollowers(ctx, ctx.User) } // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-followers-of-a-user -func ListFollowers(ctx *middleware.Context) { +func ListFollowers(ctx *context.Context) { u := GetUserByParams(ctx) if ctx.Written() { return @@ -42,7 +42,7 @@ func ListFollowers(ctx *middleware.Context) { listUserFollowers(ctx, u) } -func listUserFollowing(ctx *middleware.Context, u *models.User) { +func listUserFollowing(ctx *context.Context, u *models.User) { users, err := u.GetFollowing(ctx.QueryInt("page")) if err != nil { ctx.APIError(500, "GetFollowing", err) @@ -51,12 +51,12 @@ func listUserFollowing(ctx *middleware.Context, u *models.User) { responseApiUsers(ctx, users) } -func ListMyFollowing(ctx *middleware.Context) { +func ListMyFollowing(ctx *context.Context) { listUserFollowing(ctx, ctx.User) } // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-users-followed-by-another-user -func ListFollowing(ctx *middleware.Context) { +func ListFollowing(ctx *context.Context) { u := GetUserByParams(ctx) if ctx.Written() { return @@ -64,7 +64,7 @@ func ListFollowing(ctx *middleware.Context) { listUserFollowing(ctx, u) } -func checkUserFollowing(ctx *middleware.Context, u *models.User, followID int64) { +func checkUserFollowing(ctx *context.Context, u *models.User, followID int64) { if u.IsFollowing(followID) { ctx.Status(204) } else { @@ -73,7 +73,7 @@ func checkUserFollowing(ctx *middleware.Context, u *models.User, followID int64) } // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-you-are-following-a-user -func CheckMyFollowing(ctx *middleware.Context) { +func CheckMyFollowing(ctx *context.Context) { target := GetUserByParams(ctx) if ctx.Written() { return @@ -82,7 +82,7 @@ func CheckMyFollowing(ctx *middleware.Context) { } // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another -func CheckFollowing(ctx *middleware.Context) { +func CheckFollowing(ctx *context.Context) { u := GetUserByParams(ctx) if ctx.Written() { return @@ -95,7 +95,7 @@ func CheckFollowing(ctx *middleware.Context) { } // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#follow-a-user -func Follow(ctx *middleware.Context) { +func Follow(ctx *context.Context) { target := GetUserByParams(ctx) if ctx.Written() { return @@ -108,7 +108,7 @@ func Follow(ctx *middleware.Context) { } // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#unfollow-a-user -func Unfollow(ctx *middleware.Context) { +func Unfollow(ctx *context.Context) { target := GetUserByParams(ctx) if ctx.Written() { return diff --git a/routers/api/v1/user/keys.go b/routers/api/v1/user/keys.go index 8ba73d9934..6f387edcb1 100644 --- a/routers/api/v1/user/keys.go +++ b/routers/api/v1/user/keys.go @@ -8,13 +8,13 @@ import ( api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models" - "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/routers/api/v1/convert" "github.com/gogits/gogs/routers/api/v1/repo" ) -func GetUserByParamsName(ctx *middleware.Context, name string) *models.User { +func GetUserByParamsName(ctx *context.Context, name string) *models.User { user, err := models.GetUserByName(ctx.Params(name)) if err != nil { if models.IsErrUserNotExist(err) { @@ -28,7 +28,7 @@ func GetUserByParamsName(ctx *middleware.Context, name string) *models.User { } // GetUserByParams returns user whose name is presented in URL paramenter. -func GetUserByParams(ctx *middleware.Context) *models.User { +func GetUserByParams(ctx *context.Context) *models.User { return GetUserByParamsName(ctx, ":username") } @@ -36,7 +36,7 @@ func composePublicKeysAPILink() string { return setting.AppUrl + "api/v1/user/keys/" } -func listPublicKeys(ctx *middleware.Context, uid int64) { +func listPublicKeys(ctx *context.Context, uid int64) { keys, err := models.ListPublicKeys(uid) if err != nil { ctx.APIError(500, "ListPublicKeys", err) @@ -53,12 +53,12 @@ func listPublicKeys(ctx *middleware.Context, uid int64) { } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys -func ListMyPublicKeys(ctx *middleware.Context) { +func ListMyPublicKeys(ctx *context.Context) { listPublicKeys(ctx, ctx.User.Id) } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user -func ListPublicKeys(ctx *middleware.Context) { +func ListPublicKeys(ctx *context.Context) { user := GetUserByParams(ctx) if ctx.Written() { return @@ -67,7 +67,7 @@ func ListPublicKeys(ctx *middleware.Context) { } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key -func GetPublicKey(ctx *middleware.Context) { +func GetPublicKey(ctx *context.Context) { key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id")) if err != nil { if models.IsErrKeyNotExist(err) { @@ -83,7 +83,7 @@ func GetPublicKey(ctx *middleware.Context) { } // CreateUserPublicKey creates new public key to given user by ID. -func CreateUserPublicKey(ctx *middleware.Context, form api.CreateKeyOption, uid int64) { +func CreateUserPublicKey(ctx *context.Context, form api.CreateKeyOption, uid int64) { content, err := models.CheckPublicKeyString(form.Key) if err != nil { repo.HandleCheckKeyStringError(ctx, err) @@ -100,12 +100,12 @@ func CreateUserPublicKey(ctx *middleware.Context, form api.CreateKeyOption, uid } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key -func CreatePublicKey(ctx *middleware.Context, form api.CreateKeyOption) { +func CreatePublicKey(ctx *context.Context, form api.CreateKeyOption) { CreateUserPublicKey(ctx, form, ctx.User.Id) } // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key -func DeletePublicKey(ctx *middleware.Context) { +func DeletePublicKey(ctx *context.Context) { if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil { if models.IsErrKeyAccessDenied(err) { ctx.APIError(403, "", "You do not have access to this key") diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index 6d4b52ffdb..d08fd20241 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -10,11 +10,11 @@ import ( api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/models" - "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/context" ) // https://github.com/gogits/go-gogs-client/wiki/Users#search-users -func Search(ctx *middleware.Context) { +func Search(ctx *context.Context) { opt := models.SearchOption{ Keyword: ctx.Query("q"), Limit: com.StrTo(ctx.Query("limit")).MustInt(), @@ -52,7 +52,7 @@ func Search(ctx *middleware.Context) { } // https://github.com/gogits/go-gogs-client/wiki/Users#get-a-single-user -func GetInfo(ctx *middleware.Context) { +func GetInfo(ctx *context.Context) { u, err := models.GetUserByName(ctx.Params(":username")) if err != nil { if models.IsErrUserNotExist(err) { |