Add theme listing
This commit is contained in:
parent
b958b01635
commit
40f7d7a0be
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue