Add team listing
This commit is contained in:
parent
6ec37b83ce
commit
5a6bac928e
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue