From 8c5f42bd2b9a22cbf0cec487473c8d9a830ecf67 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Sat, 9 Jan 2021 18:13:57 +0100 Subject: [PATCH] Create a basic structure to fetch the api version Signed-off-by: Christian Wolf --- appinfo/routes.php | 1 + lib/Controller/MainController.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/appinfo/routes.php b/appinfo/routes.php index 77fe28b2..ef5edcbb 100755 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -9,6 +9,7 @@ */ return [ 'routes' => [ + ['name' => 'main#getApiVersion', 'url' => '/api/version', 'verb' => 'GET'], ['name' => 'main#index', 'url' => '/', 'verb' => 'GET'], ['name' => 'main#home', 'url' => '/home', 'verb' => 'GET'], ['name' => 'main#keywords', 'url' => '/keywords', 'verb' => 'GET'], diff --git a/lib/Controller/MainController.php b/lib/Controller/MainController.php index 8b0df907..245e13de 100755 --- a/lib/Controller/MainController.php +++ b/lib/Controller/MainController.php @@ -55,6 +55,22 @@ class MainController extends Controller { return new TemplateResponse($this->appName, 'index', $view_data); // templates/index.php } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * @return DataResponse + */ + public function getApiVersion(): DataResponse { + $response = [ + 'cookbook_version' => [0,7,7], /* VERSION_TAG */ + 'api_version' => [ + 'major' => 0, + 'minor' => 1 + ] + ]; + return new DataResponse($response, 200, ['Content-Type' => 'application/json']); + } /** * @NoAdminRequired