Add team listing

This commit is contained in:
nemunaire 2016-01-07 20:08:48 +01:00
parent 6ec37b83ce
commit 5a6bac928e
2 changed files with 28 additions and 1 deletions

View File

@ -14,7 +14,7 @@ type DispatchFunction func([]string, []byte) (interface{}, error)
var apiRouting = map[string]*(map[string]DispatchFunction){
"version": &ApiVersionRouting,
//"themes": &ApiThemesRouting,
//"teams": &ApiTeamsRouting,
"teams": &ApiTeamsRouting,
}
func ApiRouting(w http.ResponseWriter, r *http.Request) {

27
admin/api_team.go Normal file
View File

@ -0,0 +1,27 @@
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
}
}