You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "code.gitea.io/gitea/modules/context"
  7. api "code.gitea.io/sdk/gitea"
  8. )
  9. // ListStargazers list a repository's stargazers
  10. func ListStargazers(ctx *context.APIContext) {
  11. // swagger:operation GET /repos/{owner}/{repo}/stargazers repository repoListStargazers
  12. // ---
  13. // summary: List a repo's stargazers
  14. // produces:
  15. // - application/json
  16. // parameters:
  17. // - name: owner
  18. // in: path
  19. // description: owner of the repo
  20. // type: string
  21. // required: true
  22. // - name: repo
  23. // in: path
  24. // description: name of the repo
  25. // type: string
  26. // required: true
  27. // responses:
  28. // "200":
  29. // "$ref": "#/responses/UserList"
  30. stargazers, err := ctx.Repo.Repository.GetStargazers(-1)
  31. if err != nil {
  32. ctx.Error(500, "GetStargazers", err)
  33. return
  34. }
  35. users := make([]*api.User, len(stargazers))
  36. for i, stargazer := range stargazers {
  37. users[i] = stargazer.APIFormat()
  38. }
  39. ctx.JSON(200, users)
  40. }