team.go 615 B

1234567891011121314151617181920212223242526
  1. // Copyright 2016 The Gogs 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 org
  5. import (
  6. api "github.com/gogs/go-gogs-client"
  7. convert2 "gogs.io/gogs/internal/route/api/v1/convert"
  8. "gogs.io/gogs/internal/context"
  9. )
  10. func ListTeams(c *context.APIContext) {
  11. org := c.Org.Organization
  12. if err := org.GetTeams(); err != nil {
  13. c.Error(500, "GetTeams", err)
  14. return
  15. }
  16. apiTeams := make([]*api.Team, len(org.Teams))
  17. for i := range org.Teams {
  18. apiTeams[i] = convert2.ToTeam(org.Teams[i])
  19. }
  20. c.JSON(200, apiTeams)
  21. }