Added API /ping endpoint. Closes #687
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) Cachet HQ <support@cachethq.io>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||||
|
|
||||||
|
class GeneralController extends AbstractApiController
|
||||||
|
{
|
||||||
|
public function ping()
|
||||||
|
{
|
||||||
|
return $this->item('Pong!');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,9 @@ class ApiRoutes
|
|||||||
'namespace' => 'Api',
|
'namespace' => 'Api',
|
||||||
'prefix' => 'api/v1',
|
'prefix' => 'api/v1',
|
||||||
], function ($router) {
|
], function ($router) {
|
||||||
|
// General
|
||||||
|
$router->get('ping', 'GeneralController@ping');
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
$router->get('components', 'ComponentController@getComponents');
|
$router->get('components', 'ComponentController@getComponents');
|
||||||
$router->get('components/{id}', 'ComponentController@getComponent');
|
$router->get('components/{id}', 'ComponentController@getComponent');
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) Cachet HQ <support@cachethq.io>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CachetHQ\Tests\Cachet\Api;
|
||||||
|
|
||||||
|
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||||
|
|
||||||
|
class GeneralTest extends AbstractTestCase
|
||||||
|
{
|
||||||
|
public function testGetPing()
|
||||||
|
{
|
||||||
|
$this->get('/api/v1/ping');
|
||||||
|
$this->seeJson(['data' => 'Pong!']);
|
||||||
|
$this->assertResponseOk();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user