forked from forgejo/forgejo
golint fixed for routers (#208)
This commit is contained in:
parent
3a3782bb7f
commit
3917ed45de
35 changed files with 354 additions and 155 deletions
|
@ -13,7 +13,8 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/user"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Organizations#create-a-new-organization
|
||||
// CreateOrg api for create organization
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Organizations#create-a-new-organization
|
||||
func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
)
|
||||
|
||||
// GetRepositoryByParams api for getting repository by orgnizition ID and repo name
|
||||
func GetRepositoryByParams(ctx *context.APIContext) *models.Repository {
|
||||
repo, err := models.GetRepositoryByName(ctx.Org.Team.OrgID, ctx.Params(":reponame"))
|
||||
if err != nil {
|
||||
|
@ -22,6 +23,7 @@ func GetRepositoryByParams(ctx *context.APIContext) *models.Repository {
|
|||
return repo
|
||||
}
|
||||
|
||||
// AddTeamRepository api for adding a repository to a team
|
||||
func AddTeamRepository(ctx *context.APIContext) {
|
||||
repo := GetRepositoryByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -35,6 +37,7 @@ func AddTeamRepository(ctx *context.APIContext) {
|
|||
ctx.Status(204)
|
||||
}
|
||||
|
||||
// RemoveTeamRepository api for removing a repository from a team
|
||||
func RemoveTeamRepository(ctx *context.APIContext) {
|
||||
repo := GetRepositoryByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/user"
|
||||
)
|
||||
|
||||
// CreateTeam api for create a team
|
||||
func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) {
|
||||
team := &models.Team{
|
||||
OrgID: ctx.Org.Organization.ID,
|
||||
|
@ -32,6 +33,7 @@ func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) {
|
|||
ctx.JSON(201, convert.ToTeam(team))
|
||||
}
|
||||
|
||||
// AddTeamMember api for add a member to a team
|
||||
func AddTeamMember(ctx *context.APIContext) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -45,6 +47,7 @@ func AddTeamMember(ctx *context.APIContext) {
|
|||
ctx.Status(204)
|
||||
}
|
||||
|
||||
// RemoveTeamMember api for remove one member from a team
|
||||
func RemoveTeamMember(ctx *context.APIContext) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
|
|
@ -12,7 +12,8 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/user"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Repositories#create-a-new-repository
|
||||
// CreateRepo api for creating a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Repositories#create-a-new-repository
|
||||
func CreateRepo(ctx *context.APIContext, form api.CreateRepoOption) {
|
||||
owner := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
|
|
@ -34,7 +34,8 @@ func parseLoginSource(ctx *context.APIContext, u *models.User, sourceID int64, l
|
|||
u.LoginName = loginName
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-new-user
|
||||
// CreateUser api for creating a user
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-new-user
|
||||
func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
|
||||
u := &models.User{
|
||||
Name: form.Username,
|
||||
|
@ -71,7 +72,8 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) {
|
|||
ctx.JSON(201, u.APIFormat())
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#edit-an-existing-user
|
||||
// EditUser api for modifying a user's information
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Users#edit-an-existing-user
|
||||
func EditUser(ctx *context.APIContext, form api.EditUserOption) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -123,6 +125,7 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) {
|
|||
ctx.JSON(200, u.APIFormat())
|
||||
}
|
||||
|
||||
// DeleteUser api for deleting a user
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#delete-a-user
|
||||
func DeleteUser(ctx *context.APIContext) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
|
@ -144,7 +147,8 @@ func DeleteUser(ctx *context.APIContext) {
|
|||
ctx.Status(204)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-public-key-for-user
|
||||
// CreatePublicKey api for creating a public key to a user
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Administration-Users#create-a-public-key-for-user
|
||||
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
|
|
@ -9,12 +9,13 @@ import (
|
|||
|
||||
"github.com/Unknwon/com"
|
||||
|
||||
"code.gitea.io/git"
|
||||
api "code.gitea.io/sdk/gitea"
|
||||
|
||||
"code.gitea.io/git"
|
||||
"code.gitea.io/gitea/models"
|
||||
)
|
||||
|
||||
// ToEmail convert models.EmailAddress to api.Email
|
||||
func ToEmail(email *models.EmailAddress) *api.Email {
|
||||
return &api.Email{
|
||||
Email: email.Email,
|
||||
|
@ -23,6 +24,7 @@ func ToEmail(email *models.EmailAddress) *api.Email {
|
|||
}
|
||||
}
|
||||
|
||||
// ToBranch convert a commit and branch to an api.Branch
|
||||
func ToBranch(b *models.Branch, c *git.Commit) *api.Branch {
|
||||
return &api.Branch{
|
||||
Name: b.Name,
|
||||
|
@ -30,6 +32,7 @@ func ToBranch(b *models.Branch, c *git.Commit) *api.Branch {
|
|||
}
|
||||
}
|
||||
|
||||
// ToCommit convert a commit to api.PayloadCommit
|
||||
func ToCommit(c *git.Commit) *api.PayloadCommit {
|
||||
authorUsername := ""
|
||||
author, err := models.GetUserByEmail(c.Author.Email)
|
||||
|
@ -59,6 +62,7 @@ func ToCommit(c *git.Commit) *api.PayloadCommit {
|
|||
}
|
||||
}
|
||||
|
||||
// ToPublicKey convert models.PublicKey to api.PublicKey
|
||||
func ToPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey {
|
||||
return &api.PublicKey{
|
||||
ID: key.ID,
|
||||
|
@ -69,6 +73,7 @@ func ToPublicKey(apiLink string, key *models.PublicKey) *api.PublicKey {
|
|||
}
|
||||
}
|
||||
|
||||
// ToHook convert models.Webhook to api.Hook
|
||||
func ToHook(repoLink string, w *models.Webhook) *api.Hook {
|
||||
config := map[string]string{
|
||||
"url": w.URL,
|
||||
|
@ -94,6 +99,7 @@ func ToHook(repoLink string, w *models.Webhook) *api.Hook {
|
|||
}
|
||||
}
|
||||
|
||||
// ToDeployKey convert models.DeployKey to api.DeployKey
|
||||
func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
|
||||
return &api.DeployKey{
|
||||
ID: key.ID,
|
||||
|
@ -105,6 +111,7 @@ func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
|
|||
}
|
||||
}
|
||||
|
||||
// ToOrganization convert models.User to api.Organization
|
||||
func ToOrganization(org *models.User) *api.Organization {
|
||||
return &api.Organization{
|
||||
ID: org.ID,
|
||||
|
@ -117,6 +124,7 @@ func ToOrganization(org *models.User) *api.Organization {
|
|||
}
|
||||
}
|
||||
|
||||
// ToTeam convert models.Team to api.Team
|
||||
func ToTeam(team *models.Team) *api.Team {
|
||||
return &api.Team{
|
||||
ID: team.ID,
|
||||
|
|
|
@ -11,7 +11,8 @@ import (
|
|||
"code.gitea.io/gitea/modules/markdown"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-an-arbitrary-markdown-document
|
||||
// Markdown render markdown document to HTML
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-an-arbitrary-markdown-document
|
||||
func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
|
||||
if ctx.HasApiError() {
|
||||
ctx.Error(422, "", ctx.GetErrMsg())
|
||||
|
@ -31,7 +32,8 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
|
|||
}
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-a-markdown-document-in-raw-mode
|
||||
// MarkdownRaw render raw markdown HTML
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-a-markdown-document-in-raw-mode
|
||||
func MarkdownRaw(ctx *context.APIContext) {
|
||||
body, err := ctx.Req.Body().Bytes()
|
||||
if err != nil {
|
||||
|
|
|
@ -26,12 +26,14 @@ func listUserOrgs(ctx *context.APIContext, u *models.User, all bool) {
|
|||
ctx.JSON(200, &apiOrgs)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Organizations#list-your-organizations
|
||||
// ListMyOrgs list all my orgs
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#list-your-organizations
|
||||
func ListMyOrgs(ctx *context.APIContext) {
|
||||
listUserOrgs(ctx, ctx.User, true)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Organizations#list-user-organizations
|
||||
// ListUserOrgs list user's orgs
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#list-user-organizations
|
||||
func ListUserOrgs(ctx *context.APIContext) {
|
||||
u := user.GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -40,12 +42,14 @@ func ListUserOrgs(ctx *context.APIContext) {
|
|||
listUserOrgs(ctx, u, false)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Organizations#get-an-organization
|
||||
// Get get an organization
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#get-an-organization
|
||||
func Get(ctx *context.APIContext) {
|
||||
ctx.JSON(200, convert.ToOrganization(ctx.Org.Organization))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization
|
||||
// Edit change an organization's information
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization
|
||||
func Edit(ctx *context.APIContext, form api.EditOrgOption) {
|
||||
org := ctx.Org.Organization
|
||||
if !org.IsOwnedBy(ctx.User.ID) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// ListTeams list all the teams of an organization
|
||||
func ListTeams(ctx *context.APIContext) {
|
||||
org := ctx.Org.Organization
|
||||
if err := org.GetTeams(); err != nil {
|
||||
|
|
|
@ -11,7 +11,8 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch
|
||||
// GetBranch get a branch of a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#get-branch
|
||||
func GetBranch(ctx *context.APIContext) {
|
||||
branch, err := ctx.Repo.Repository.GetBranch(ctx.Params(":branchname"))
|
||||
if err != nil {
|
||||
|
@ -28,7 +29,8 @@ func GetBranch(ctx *context.APIContext) {
|
|||
ctx.JSON(200, convert.ToBranch(branch, c))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches
|
||||
// ListBranches list all the branches of a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-branches
|
||||
func ListBranches(ctx *context.APIContext) {
|
||||
branches, err := ctx.Repo.Repository.GetBranches()
|
||||
if err != nil {
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
)
|
||||
|
||||
// AddCollaborator add a collaborator of a repository
|
||||
func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
|
||||
collaborator, err := models.GetUserByName(ctx.Params(":collaborator"))
|
||||
if err != nil {
|
||||
|
|
|
@ -12,7 +12,8 @@ import (
|
|||
"code.gitea.io/gitea/routers/repo"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content
|
||||
// GetRawFile get a file by path on a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-raw-content
|
||||
func GetRawFile(ctx *context.APIContext) {
|
||||
if !ctx.Repo.HasAccess() {
|
||||
ctx.Status(404)
|
||||
|
@ -33,7 +34,8 @@ func GetRawFile(ctx *context.APIContext) {
|
|||
}
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive
|
||||
// GetArchive get archive of a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Contents#download-archive
|
||||
func GetArchive(ctx *context.APIContext) {
|
||||
repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame"))
|
||||
gitRepo, err := git.OpenRepository(repoPath)
|
||||
|
@ -46,6 +48,7 @@ func GetArchive(ctx *context.APIContext) {
|
|||
repo.Download(ctx.Context)
|
||||
}
|
||||
|
||||
// GetEditorconfig get editor config of a repository
|
||||
func GetEditorconfig(ctx *context.APIContext) {
|
||||
ec, err := ctx.Repo.GetEditorconfig()
|
||||
if err != nil {
|
||||
|
|
|
@ -16,7 +16,8 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks
|
||||
// ListHooks list all hooks of a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks
|
||||
func ListHooks(ctx *context.APIContext) {
|
||||
hooks, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
|
@ -31,7 +32,8 @@ func ListHooks(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &apiHooks)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#create-a-hook
|
||||
// CreateHook create a hook for a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#create-a-hook
|
||||
func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
||||
if !models.IsValidHookTaskType(form.Type) {
|
||||
ctx.Error(422, "", "Invalid hook type")
|
||||
|
@ -97,7 +99,8 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
|
|||
ctx.JSON(201, convert.ToHook(ctx.Repo.RepoLink, w))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook
|
||||
// EditHook modify a hook of a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook
|
||||
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
|
||||
w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
|
@ -165,6 +168,7 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) {
|
|||
ctx.JSON(200, convert.ToHook(ctx.Repo.RepoLink, w))
|
||||
}
|
||||
|
||||
// DeleteHook delete a hook of a repository
|
||||
func DeleteHook(ctx *context.APIContext) {
|
||||
if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
|
||||
ctx.Error(500, "DeleteWebhookByRepoID", err)
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
||||
// ListIssues list the issues of a repository
|
||||
func ListIssues(ctx *context.APIContext) {
|
||||
issues, err := models.Issues(&models.IssuesOptions{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
|
@ -39,6 +40,7 @@ func ListIssues(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &apiIssues)
|
||||
}
|
||||
|
||||
// GetIssue get an issue of a repository
|
||||
func GetIssue(ctx *context.APIContext) {
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
|
@ -52,6 +54,7 @@ func GetIssue(ctx *context.APIContext) {
|
|||
ctx.JSON(200, issue.APIFormat())
|
||||
}
|
||||
|
||||
// CreateIssue create an issue of a repository
|
||||
func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
|
||||
issue := &models.Issue{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
|
@ -101,6 +104,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
|
|||
ctx.JSON(201, issue.APIFormat())
|
||||
}
|
||||
|
||||
// EditIssue modify an issue of a repository
|
||||
func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repo
|
||||
|
||||
import (
|
||||
|
@ -12,6 +13,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
)
|
||||
|
||||
// ListIssueComments list all the comments of an issue
|
||||
func ListIssueComments(ctx *context.APIContext) {
|
||||
var since time.Time
|
||||
if len(ctx.Query("since")) > 0 {
|
||||
|
@ -38,6 +40,7 @@ func ListIssueComments(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &apiComments)
|
||||
}
|
||||
|
||||
// CreateIssueComment create a comment for an issue
|
||||
func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOption) {
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
|
@ -54,6 +57,7 @@ func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOpti
|
|||
ctx.JSON(201, comment.APIFormat())
|
||||
}
|
||||
|
||||
// EditIssueComment modify a comment of an issue
|
||||
func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) {
|
||||
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
)
|
||||
|
||||
// ListIssueLabels list all the labels of an issue
|
||||
func ListIssueLabels(ctx *context.APIContext) {
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
|
@ -29,6 +30,7 @@ func ListIssueLabels(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &apiLabels)
|
||||
}
|
||||
|
||||
// AddIssueLabels add labels for an issue
|
||||
func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
ctx.Status(403)
|
||||
|
@ -69,6 +71,7 @@ func AddIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
|||
ctx.JSON(200, &apiLabels)
|
||||
}
|
||||
|
||||
// DeleteIssueLabel delete a label for an issue
|
||||
func DeleteIssueLabel(ctx *context.APIContext) {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
ctx.Status(403)
|
||||
|
@ -103,6 +106,7 @@ func DeleteIssueLabel(ctx *context.APIContext) {
|
|||
ctx.Status(204)
|
||||
}
|
||||
|
||||
// ReplaceIssueLabels replace labels for an issue
|
||||
func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
ctx.Status(403)
|
||||
|
@ -143,6 +147,7 @@ func ReplaceIssueLabels(ctx *context.APIContext, form api.IssueLabelsOption) {
|
|||
ctx.JSON(200, &apiLabels)
|
||||
}
|
||||
|
||||
// ClearIssueLabels delete all the labels for an issue
|
||||
func ClearIssueLabels(ctx *context.APIContext) {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
ctx.Status(403)
|
||||
|
|
|
@ -19,7 +19,8 @@ func composeDeployKeysAPILink(repoPath string) string {
|
|||
return setting.AppUrl + "api/v1/repos/" + repoPath + "/keys/"
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#list-deploy-keys
|
||||
// ListDeployKeys list all the deploy keys of a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#list-deploy-keys
|
||||
func ListDeployKeys(ctx *context.APIContext) {
|
||||
keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
|
@ -40,7 +41,8 @@ func ListDeployKeys(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &apiKeys)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#get-a-deploy-key
|
||||
// GetDeployKey get a deploy key by id
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#get-a-deploy-key
|
||||
func GetDeployKey(ctx *context.APIContext) {
|
||||
key, err := models.GetDeployKeyByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
|
@ -61,6 +63,7 @@ func GetDeployKey(ctx *context.APIContext) {
|
|||
ctx.JSON(200, convert.ToDeployKey(apiLink, key))
|
||||
}
|
||||
|
||||
// HandleCheckKeyStringError handle check key error
|
||||
func HandleCheckKeyStringError(ctx *context.APIContext, err error) {
|
||||
if models.IsErrKeyUnableVerify(err) {
|
||||
ctx.Error(422, "", "Unable to verify key content")
|
||||
|
@ -69,6 +72,7 @@ func HandleCheckKeyStringError(ctx *context.APIContext, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// HandleAddKeyError handle add key error
|
||||
func HandleAddKeyError(ctx *context.APIContext, err error) {
|
||||
switch {
|
||||
case models.IsErrKeyAlreadyExist(err):
|
||||
|
@ -80,7 +84,8 @@ func HandleAddKeyError(ctx *context.APIContext, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#add-a-new-deploy-key
|
||||
// CreateDeployKey create deploy key for a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#add-a-new-deploy-key
|
||||
func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
||||
content, err := models.CheckPublicKeyString(form.Key)
|
||||
if err != nil {
|
||||
|
@ -99,7 +104,8 @@ func CreateDeployKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
|||
ctx.JSON(201, convert.ToDeployKey(apiLink, key))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key
|
||||
// DeleteDeploykey delete deploy key for a repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#remove-a-deploy-key
|
||||
func DeleteDeploykey(ctx *context.APIContext) {
|
||||
if err := models.DeleteDeployKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
||||
if models.IsErrKeyAccessDenied(err) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
)
|
||||
|
||||
// ListLabels list all the labels of a repository
|
||||
func ListLabels(ctx *context.APIContext) {
|
||||
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
|
@ -25,6 +26,7 @@ func ListLabels(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &apiLabels)
|
||||
}
|
||||
|
||||
// GetLabel get label by repository and label id
|
||||
func GetLabel(ctx *context.APIContext) {
|
||||
label, err := models.GetLabelInRepoByID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
|
@ -39,6 +41,7 @@ func GetLabel(ctx *context.APIContext) {
|
|||
ctx.JSON(200, label.APIFormat())
|
||||
}
|
||||
|
||||
// CreateLabel create a label for a repository
|
||||
func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
ctx.Status(403)
|
||||
|
@ -57,6 +60,7 @@ func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) {
|
|||
ctx.JSON(201, label.APIFormat())
|
||||
}
|
||||
|
||||
// EditLabel modify a label for a repository
|
||||
func EditLabel(ctx *context.APIContext, form api.EditLabelOption) {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
ctx.Status(403)
|
||||
|
@ -86,6 +90,7 @@ func EditLabel(ctx *context.APIContext, form api.EditLabelOption) {
|
|||
ctx.JSON(200, label.APIFormat())
|
||||
}
|
||||
|
||||
// DeleteLabel delete a label for a repository
|
||||
func DeleteLabel(ctx *context.APIContext) {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
ctx.Status(403)
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
)
|
||||
|
||||
// ListMilestones list all the milestones for a repository
|
||||
func ListMilestones(ctx *context.APIContext) {
|
||||
milestones, err := models.GetMilestonesByRepoID(ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
|
@ -27,6 +28,7 @@ func ListMilestones(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &apiMilestones)
|
||||
}
|
||||
|
||||
// GetMilestone get a milestone for a repository
|
||||
func GetMilestone(ctx *context.APIContext) {
|
||||
milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
|
@ -40,6 +42,7 @@ func GetMilestone(ctx *context.APIContext) {
|
|||
ctx.JSON(200, milestone.APIFormat())
|
||||
}
|
||||
|
||||
// CreateMilestone create a milestone for a repository
|
||||
func CreateMilestone(ctx *context.APIContext, form api.CreateMilestoneOption) {
|
||||
if form.Deadline == nil {
|
||||
defaultDeadline, _ := time.ParseInLocation("2006-01-02", "9999-12-31", time.Local)
|
||||
|
@ -60,6 +63,7 @@ func CreateMilestone(ctx *context.APIContext, form api.CreateMilestoneOption) {
|
|||
ctx.JSON(201, milestone.APIFormat())
|
||||
}
|
||||
|
||||
// EditMilestone modify a milestone for a repository
|
||||
func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) {
|
||||
milestone, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
|
@ -88,6 +92,7 @@ func EditMilestone(ctx *context.APIContext, form api.EditMilestoneOption) {
|
|||
ctx.JSON(200, milestone.APIFormat())
|
||||
}
|
||||
|
||||
// DeleteMilestone delete a milestone for a repository
|
||||
func DeleteMilestone(ctx *context.APIContext) {
|
||||
if err := models.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
|
||||
ctx.Error(500, "DeleteMilestoneByRepoID", err)
|
||||
|
|
|
@ -17,7 +17,8 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#search-repositories
|
||||
// Search repositories via options
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#search-repositories
|
||||
func Search(ctx *context.APIContext) {
|
||||
opts := &models.SearchRepoOptions{
|
||||
Keyword: path.Base(ctx.Query("q")),
|
||||
|
@ -76,7 +77,8 @@ func Search(ctx *context.APIContext) {
|
|||
})
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-your-repositories
|
||||
// ListMyRepos list all my repositories
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-your-repositories
|
||||
func ListMyRepos(ctx *context.APIContext) {
|
||||
ownRepos, err := models.GetUserRepositories(ctx.User.ID, true, 1, ctx.User.NumRepos)
|
||||
if err != nil {
|
||||
|
@ -109,6 +111,7 @@ func ListMyRepos(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &repos)
|
||||
}
|
||||
|
||||
// CreateUserRepo create a repository for a user
|
||||
func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateRepoOption) {
|
||||
repo, err := models.CreateRepository(owner, models.CreateRepoOptions{
|
||||
Name: opt.Name,
|
||||
|
@ -138,7 +141,8 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
|
|||
ctx.JSON(201, repo.APIFormat(&api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#create
|
||||
// Create create one repository of mine
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#create
|
||||
func Create(ctx *context.APIContext, opt api.CreateRepoOption) {
|
||||
// Shouldn't reach this condition, but just in case.
|
||||
if ctx.User.IsOrganization() {
|
||||
|
@ -148,6 +152,7 @@ func Create(ctx *context.APIContext, opt api.CreateRepoOption) {
|
|||
CreateUserRepo(ctx, ctx.User, opt)
|
||||
}
|
||||
|
||||
// CreateOrgRepo create one repository of the organization
|
||||
func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) {
|
||||
org, err := models.GetOrgByName(ctx.Params(":org"))
|
||||
if err != nil {
|
||||
|
@ -166,7 +171,8 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) {
|
|||
CreateUserRepo(ctx, org, opt)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#migrate
|
||||
// Migrate migrate remote git repository to gitea
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#migrate
|
||||
func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
|
||||
ctxUser := ctx.User
|
||||
// Not equal means context user is an organization,
|
||||
|
@ -238,13 +244,15 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
|
|||
ctx.JSON(201, repo.APIFormat(&api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#get
|
||||
// Get get one repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#get
|
||||
func Get(ctx *context.APIContext) {
|
||||
repo := ctx.Repo.Repository
|
||||
ctx.JSON(200, repo.APIFormat(&api.Permission{true, true, true}))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Repositories#delete
|
||||
// Delete delete one repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#delete
|
||||
func Delete(ctx *context.APIContext) {
|
||||
owner := ctx.Repo.Owner
|
||||
repo := ctx.Repo.Repository
|
||||
|
|
|
@ -11,7 +11,8 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users#list-access-tokens-for-a-user
|
||||
// ListAccessTokens list all the access tokens
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users#list-access-tokens-for-a-user
|
||||
func ListAccessTokens(ctx *context.APIContext) {
|
||||
tokens, err := models.ListAccessTokens(ctx.User.ID)
|
||||
if err != nil {
|
||||
|
@ -26,7 +27,8 @@ func ListAccessTokens(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &apiTokens)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users#create-a-access-token
|
||||
// CreateAccessToken create access tokens
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users#create-a-access-token
|
||||
func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption) {
|
||||
t := &models.AccessToken{
|
||||
UID: ctx.User.ID,
|
||||
|
|
|
@ -13,7 +13,8 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||
)
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user
|
||||
// ListEmails list all the emails of mine
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user
|
||||
func ListEmails(ctx *context.APIContext) {
|
||||
emails, err := models.GetEmailAddresses(ctx.User.ID)
|
||||
if err != nil {
|
||||
|
@ -27,7 +28,8 @@ func ListEmails(ctx *context.APIContext) {
|
|||
ctx.JSON(200, &apiEmails)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses
|
||||
// AddEmail add email for me
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#add-email-addresses
|
||||
func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) {
|
||||
if len(form.Emails) == 0 {
|
||||
ctx.Status(422)
|
||||
|
@ -59,7 +61,8 @@ func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) {
|
|||
ctx.JSON(201, &apiEmails)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses
|
||||
// DeleteEmail delete email
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Emails#delete-email-addresses
|
||||
func DeleteEmail(ctx *context.APIContext, form api.CreateEmailOption) {
|
||||
if len(form.Emails) == 0 {
|
||||
ctx.Status(204)
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
)
|
||||
|
||||
func responseApiUsers(ctx *context.APIContext, users []*models.User) {
|
||||
func responseAPIUsers(ctx *context.APIContext, users []*models.User) {
|
||||
apiUsers := make([]*api.User, len(users))
|
||||
for i := range users {
|
||||
apiUsers[i] = users[i].APIFormat()
|
||||
|
@ -25,14 +25,16 @@ func listUserFollowers(ctx *context.APIContext, u *models.User) {
|
|||
ctx.Error(500, "GetUserFollowers", err)
|
||||
return
|
||||
}
|
||||
responseApiUsers(ctx, users)
|
||||
responseAPIUsers(ctx, users)
|
||||
}
|
||||
|
||||
// ListMyFollowers list all my followers
|
||||
func ListMyFollowers(ctx *context.APIContext) {
|
||||
listUserFollowers(ctx, ctx.User)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-followers-of-a-user
|
||||
// ListFollowers list user's followers
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-followers-of-a-user
|
||||
func ListFollowers(ctx *context.APIContext) {
|
||||
u := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -47,14 +49,16 @@ func listUserFollowing(ctx *context.APIContext, u *models.User) {
|
|||
ctx.Error(500, "GetFollowing", err)
|
||||
return
|
||||
}
|
||||
responseApiUsers(ctx, users)
|
||||
responseAPIUsers(ctx, users)
|
||||
}
|
||||
|
||||
// ListMyFollowing list all my followings
|
||||
func ListMyFollowing(ctx *context.APIContext) {
|
||||
listUserFollowing(ctx, ctx.User)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-users-followed-by-another-user
|
||||
// ListFollowing list user's followings
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#list-users-followed-by-another-user
|
||||
func ListFollowing(ctx *context.APIContext) {
|
||||
u := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -71,7 +75,8 @@ func checkUserFollowing(ctx *context.APIContext, u *models.User, followID int64)
|
|||
}
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-you-are-following-a-user
|
||||
// CheckMyFollowing check if the repo is followed by me
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-you-are-following-a-user
|
||||
func CheckMyFollowing(ctx *context.APIContext) {
|
||||
target := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -80,7 +85,8 @@ func CheckMyFollowing(ctx *context.APIContext) {
|
|||
checkUserFollowing(ctx, ctx.User, target.ID)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another
|
||||
// CheckFollowing check if the repo is followed by user
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another
|
||||
func CheckFollowing(ctx *context.APIContext) {
|
||||
u := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -93,7 +99,8 @@ func CheckFollowing(ctx *context.APIContext) {
|
|||
checkUserFollowing(ctx, u, target.ID)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#follow-a-user
|
||||
// Follow follow one repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#follow-a-user
|
||||
func Follow(ctx *context.APIContext) {
|
||||
target := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -106,7 +113,8 @@ func Follow(ctx *context.APIContext) {
|
|||
ctx.Status(204)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#unfollow-a-user
|
||||
// Unfollow unfollow one repository
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Followers#unfollow-a-user
|
||||
func Unfollow(ctx *context.APIContext) {
|
||||
target := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"code.gitea.io/gitea/routers/api/v1/repo"
|
||||
)
|
||||
|
||||
// GetUserByParamsName get user by name
|
||||
func GetUserByParamsName(ctx *context.APIContext, name string) *models.User {
|
||||
user, err := models.GetUserByName(ctx.Params(name))
|
||||
if err != nil {
|
||||
|
@ -52,12 +53,14 @@ func listPublicKeys(ctx *context.APIContext, uid int64) {
|
|||
ctx.JSON(200, &apiKeys)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys
|
||||
// ListMyPublicKeys list all my public keys
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys
|
||||
func ListMyPublicKeys(ctx *context.APIContext) {
|
||||
listPublicKeys(ctx, ctx.User.ID)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user
|
||||
// ListPublicKeys list all user's public keys
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user
|
||||
func ListPublicKeys(ctx *context.APIContext) {
|
||||
user := GetUserByParams(ctx)
|
||||
if ctx.Written() {
|
||||
|
@ -66,7 +69,8 @@ func ListPublicKeys(ctx *context.APIContext) {
|
|||
listPublicKeys(ctx, user.ID)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key
|
||||
// GetPublicKey get one public key
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key
|
||||
func GetPublicKey(ctx *context.APIContext) {
|
||||
key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
|
@ -99,12 +103,14 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid
|
|||
ctx.JSON(201, convert.ToPublicKey(apiLink, key))
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key
|
||||
// CreatePublicKey create one public key for me
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key
|
||||
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
|
||||
CreateUserPublicKey(ctx, form, ctx.User.ID)
|
||||
}
|
||||
|
||||
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key
|
||||
// DeletePublicKey delete one public key of mine
|
||||
// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key
|
||||
func DeletePublicKey(ctx *context.APIContext) {
|
||||
if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
||||
if models.IsErrKeyAccessDenied(err) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
)
|
||||
|
||||
// Search search users
|
||||
func Search(ctx *context.APIContext) {
|
||||
opts := &models.SearchUserOptions{
|
||||
Keyword: ctx.Query("q"),
|
||||
|
@ -51,6 +52,7 @@ func Search(ctx *context.APIContext) {
|
|||
})
|
||||
}
|
||||
|
||||
// GetInfo get user's information
|
||||
func GetInfo(ctx *context.APIContext) {
|
||||
u, err := models.GetUserByName(ctx.Params(":username"))
|
||||
if err != nil {
|
||||
|
@ -69,6 +71,7 @@ func GetInfo(ctx *context.APIContext) {
|
|||
ctx.JSON(200, u.APIFormat())
|
||||
}
|
||||
|
||||
// GetAuthenticatedUser get curent user's information
|
||||
func GetAuthenticatedUser(ctx *context.APIContext) {
|
||||
ctx.JSON(200, ctx.User.APIFormat())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue