From 1e019a9e25470449dc6ab544b919e356e3b4aaec Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Mon, 23 Aug 2021 17:03:00 +0800 Subject: [PATCH] + Add configurations of api. --- api/v1/entries/config.php | 36 ++++++++++++++++++++++++++++++++++++ api/v1/entries/configs.php | 22 ++++++++++++++++++++++ config/routes.php | 3 +++ 3 files changed, 61 insertions(+) create mode 100644 api/v1/entries/config.php create mode 100644 api/v1/entries/configs.php diff --git a/api/v1/entries/config.php b/api/v1/entries/config.php new file mode 100644 index 0000000000..0e7c01f880 --- /dev/null +++ b/api/v1/entries/config.php @@ -0,0 +1,36 @@ + $name); + + switch($name) + { + case 'language': + $config['value'] = $this->config->default->lang; + break; + case 'version': + $config['value'] = $this->config->version; + break; + case 'charset': + $config['value'] = $this->config->charset; + break; + case 'timezone': + $config['value'] = $this->config->timezone; + break; + default: + $this->sendError(400, 'No configuration.'); + return; + } + + $this->send(200, $config); + } +} diff --git a/api/v1/entries/configs.php b/api/v1/entries/configs.php new file mode 100644 index 0000000000..b55bc5102f --- /dev/null +++ b/api/v1/entries/configs.php @@ -0,0 +1,22 @@ + 'language', 'value' => $this->config->default->lang); + $configs[] = array('key' => 'version', 'value' => $this->config->version); + $configs[] = array('key' => 'charset', 'value' => $this->config->charset); + $configs[] = array('key' => 'timezone', 'value' => $this->config->timezone); + + $this->send(200, $configs); + } +} diff --git a/config/routes.php b/config/routes.php index fe31f8b5ef..32ddd1ee81 100644 --- a/config/routes.php +++ b/config/routes.php @@ -6,6 +6,9 @@ $routes = array(); $routes['/tokens'] = 'tokens'; +$routes['/configurations'] = 'configs'; +$routes['/configurations/:name'] = 'config'; + $routes['/products'] = 'products'; $routes['/products/:id'] = 'product'; $routes['/productlines'] = 'productLines';