28 lines
503 B
Go
28 lines
503 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
var ApiTeamsRouting = map[string]DispatchFunction{
|
||
|
"GET": list,
|
||
|
}
|
||
|
|
||
|
func list(args []string, body []byte) (interface{}, error) {
|
||
|
if len(args) == 1 {
|
||
|
// List given team
|
||
|
if tid, err := strconv.Atoi(string(args[0])); err != nil {
|
||
|
return nil, err
|
||
|
} else if team, err := GetTeam(tid); err != nil {
|
||
|
return nil, err
|
||
|
} else {
|
||
|
return team.GetMembers()
|
||
|
}
|
||
|
} else if len(args) == 0 {
|
||
|
// List all teams
|
||
|
return GetTeams()
|
||
|
} else {
|
||
|
return nil, nil
|
||
|
}
|
||
|
}
|