Add team listing
This commit is contained in:
parent
6ec37b83ce
commit
5a6bac928e
2 changed files with 28 additions and 1 deletions
|
@ -14,7 +14,7 @@ type DispatchFunction func([]string, []byte) (interface{}, error)
|
||||||
var apiRouting = map[string]*(map[string]DispatchFunction){
|
var apiRouting = map[string]*(map[string]DispatchFunction){
|
||||||
"version": &ApiVersionRouting,
|
"version": &ApiVersionRouting,
|
||||||
//"themes": &ApiThemesRouting,
|
//"themes": &ApiThemesRouting,
|
||||||
//"teams": &ApiTeamsRouting,
|
"teams": &ApiTeamsRouting,
|
||||||
}
|
}
|
||||||
|
|
||||||
func ApiRouting(w http.ResponseWriter, r *http.Request) {
|
func ApiRouting(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
27
admin/api_team.go
Normal file
27
admin/api_team.go
Normal 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
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue