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.

25 lines
629 B

  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. api "code.gitea.io/sdk/gitea"
  7. "code.gitea.io/gitea/modules/context"
  8. )
  9. // ListStargazers list a repository's stargazers
  10. func ListStargazers(ctx *context.APIContext) {
  11. stargazers, err := ctx.Repo.Repository.GetStargazers(-1)
  12. if err != nil {
  13. ctx.Error(500, "GetStargazers", err)
  14. return
  15. }
  16. users := make([]*api.User, len(stargazers))
  17. for i, stargazer := range stargazers {
  18. users[i] = stargazer.APIFormat()
  19. }
  20. ctx.JSON(200, users)
  21. }