Skip to content
Snippets Groups Projects
Commit 3b73c672 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

refactor(rest-api): move rest api's enabled flag to the RestApi config

parent 68777dd5
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ cache.handler="file"
# cache.redis.port=6379
# cache.redis.database=0
#REST API configuration
#--------------------------------------------------------------------
# 0/1 Disabled/Enabled
REST_API_ENABLED=1
\ No newline at end of file
# REST API configuration
#--------------------------------------------------------------------
# restapi.enabled=true
<?php
declare(strict_types=1);
namespace Modules\Api\Rest\V1\Config;
use CodeIgniter\Config\BaseConfig;
class Api extends BaseConfig
class RestApi extends BaseConfig
{
/**
* Flag to enable or disable the Rest API.
*
* Disabled by default.
*/
public bool $enabled = false;
/**
* --------------------------------------------------------------------------
* Rest API gateway
......
......@@ -7,7 +7,7 @@ namespace Modules\Api\Rest\V1\Config;
$routes = service('routes');
$routes->group(
config('Api')
config('RestApi')
->gateway . 'podcasts',
[
'namespace' => 'Modules\Api\Rest\V1\Controllers',
......
......@@ -13,7 +13,7 @@ class ApiFilter implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null): void
{
if (! getenv('REST_API_ENABLED')) {
if (! config('RestApi')->enabled) {
throw PageNotFoundException::forPageNotFound();
}
}
......
......@@ -51,6 +51,6 @@
<env name="database.tests.password" value="castopod"/>
<env name="database.tests.DBDriver" value="MySQLi"/>
<env name="database.tests.DBPrefix" value="tests_"/>
<env name="REST_API_ENABLED" value="1"/>
<env name="restapi.enabled" value="true"/>
</php>
</phpunit>
......@@ -55,7 +55,7 @@ class PodcastTest extends CIUnitTestCase
$this->podcast = FakeSinglePodcastApiSeeder::podcast();
$this->podcast['created_at'] = [];
$this->podcast['updated_at'] = [];
$this->podcastApiUrl = config('Api')
$this->podcastApiUrl = config('RestApi')
->gateway;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment