Skip to content

Commit c66a1cb

Browse files
author
Angel Garcia
committed
Added HealthCheck endpoint to base ActiveController
1 parent 8468780 commit c66a1cb

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

api/modules/v1/controllers/UserController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,5 @@
77

88
class UserController extends ActiveController
99
{
10-
public function actionStatus()
11-
{
12-
return 'online';
13-
}
1410

1511
}
Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
<?php
22

3-
namespace base\rest;
3+
namespace base\rest;
44

5-
use common\filters\CustomCors;
6-
use Yii;
7-
use yii\filters\auth\CompositeAuth;
8-
use yii\filters\auth\HttpBearerAuth;
9-
use yii\web\Response;
5+
use common\filters\CustomCors;
6+
use Yii;
7+
use yii\filters\auth\CompositeAuth;
8+
use yii\filters\auth\HttpBearerAuth;
9+
use yii\web\Response;
1010

11-
class ActiveController extends \yii\rest\ActiveController
11+
class ActiveController extends \yii\rest\ActiveController
12+
{
13+
public function behaviors()
1214
{
13-
public function behaviors()
14-
{
15-
return array_merge(parent::behaviors(), [
16-
'corsFilter' => [
17-
'class' => CustomCors::class,
18-
'cors' => [
19-
'Origin' => Yii::$app->params['CORS'],
20-
'Access-Control-Request-Method' => ['POST', 'GET', 'PUT', 'OPTIONS'],
21-
'Access-Control-Request-Headers' => ['Authorization', 'Content-type', 'Credentials'],
22-
'Access-Control-Allow-Credentials' => true,
23-
],
15+
return array_merge(parent::behaviors(), [
16+
'corsFilter' => [
17+
'class' => CustomCors::class,
18+
'cors' => [
19+
'Origin' => Yii::$app->params['CORS'],
20+
'Access-Control-Request-Method' => ['POST', 'GET', 'PUT', 'OPTIONS'],
21+
'Access-Control-Request-Headers' => ['Authorization', 'Content-type', 'Credentials'],
22+
'Access-Control-Allow-Credentials' => true,
2423
],
25-
[
26-
'class' => 'yii\filters\ContentNegotiator',
27-
'formats' => [
28-
'application/json' => Response::FORMAT_JSON,
29-
],
24+
],
25+
[
26+
'class' => 'yii\filters\ContentNegotiator',
27+
'formats' => [
28+
'application/json' => Response::FORMAT_JSON,
3029
],
31-
[
32-
'class' => CompositeAuth::class,
33-
'except' => [],
34-
'authMethods' => [
35-
HttpBearerAuth::class,
36-
],
37-
]
38-
]);
39-
}
40-
30+
],
31+
[
32+
'class' => CompositeAuth::class,
33+
'except' => ['status'],
34+
'authMethods' => [
35+
HttpBearerAuth::class,
36+
],
37+
]
38+
]);
39+
}
4140

41+
public function actionStatus()
42+
{
43+
return 'online';
4244
}
45+
46+
47+
}

init

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,5 @@ function formatMessage($message, $styles)
311311
// TODO Set up environments configuration
312312
// TODO Set up and fix console and migrations instructions
313313
// TODO Fix common / models
314-
// TODO Finish adding components
315314
// TODO Add CORS config to readme
316315
// TODO Add components description and ussage

0 commit comments

Comments
 (0)