mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-19 13:01:19 +00:00
refactor(rest-api): move rest api's enabled flag to the RestApi config
This commit is contained in:
parent
68777dd54c
commit
3b73c67250
@ -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
|
||||
# REST API configuration
|
||||
#--------------------------------------------------------------------
|
||||
# restapi.enabled=true
|
||||
|
@ -1,14 +1,20 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user