Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@
* The controller class has to be registered in the application.php file since
* it's instantiated in there
*/

return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#do_echo', 'url' => '/echo', 'verb' => 'POST'],
]
['name' => 'page#update', 'url' => '/update', 'verb' => 'GET'],
],
'ocs' => [
['name' => 'api#info', 'url' => '/api/v1/info', 'verb' => 'GET'],
]
];
52 changes: 52 additions & 0 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* @copyright Copyright (c) 2016 Bjoern Schiessle <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


namespace OCA\ServerInfo\Controller;

use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;

class ApiController extends OCSController {


public function __construct($appName,
\OCP\IRequest $request) {
parent::__construct($appName, $request);
}

/**
* @NoCSRFRequired
*
* @return DataResponse
*/
public function info() {
return new DataResponse(
['data' =>
[
'key' => 'value'
]
]
);

}

}
12 changes: 9 additions & 3 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace OCA\ServerInfo\Controller;

use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\DataResponse;
Expand Down Expand Up @@ -50,11 +51,16 @@ public function index() {
/**
* request data update
*
* @return TemplateResponse
* @return JSONResponse
*/
public function update() {
$params = ['users' => 100];
return new TemplateResponse('serverinfo', 'main', $params); // templates/main.php
$data = [
'users' => 100,
'freespace' => 1024
];

return new JSONResponse($data);


}

Expand Down