Add theme listing

This commit is contained in:
nemunaire 2016-01-07 20:47:07 +01:00
parent b958b01635
commit 40f7d7a0be
2 changed files with 26 additions and 1 deletions

View File

@ -13,7 +13,7 @@ type DispatchFunction func([]string, []byte) (interface{}, error)
var apiRouting = map[string]*(map[string]DispatchFunction){
"version": &ApiVersionRouting,
//"themes": &ApiThemesRouting,
"themes": &ApiThemesRouting,
"teams": &ApiTeamsRouting,
}

25
admin/api_theme.go Normal file
View File

@ -0,0 +1,25 @@
package main
import (
"strconv"
)
var ApiThemesRouting = map[string]DispatchFunction{
"GET": listTheme,
}
func listTheme(args []string, body []byte) (interface{}, error) {
if len(args) == 1 {
// List given theme
if tid, err := strconv.Atoi(string(args[0])); err != nil {
return nil, err
} else {
return GetTheme(tid)
}
} else if len(args) == 0 {
// List all themes
return GetThemes()
} else {
return nil, nil
}
}