26 lines
442 B
Go
26 lines
442 B
Go
|
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
|
||
|
}
|
||
|
}
|