From 40f7d7a0be2ae1f80a9c45ac585c62ad1a76274f Mon Sep 17 00:00:00 2001 From: nemunaire Date: Thu, 7 Jan 2016 20:47:07 +0100 Subject: [PATCH] Add theme listing --- admin/api.go | 2 +- admin/api_theme.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 admin/api_theme.go diff --git a/admin/api.go b/admin/api.go index 647a883c..3e024278 100644 --- a/admin/api.go +++ b/admin/api.go @@ -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, } diff --git a/admin/api_theme.go b/admin/api_theme.go new file mode 100644 index 00000000..52d8d429 --- /dev/null +++ b/admin/api_theme.go @@ -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 + } +}