Cambios de usos de env vars
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
return [
|
||||
'urls' => function() {
|
||||
'urls' => function(ContainerInterface $container) {
|
||||
$urls = [
|
||||
'base' => $_ENV['APP_URL'] ?? '',
|
||||
'base' => $container->get('APP_URL') ?? '',
|
||||
];
|
||||
$urls['api'] = implode('/', [
|
||||
$urls['base'],
|
||||
@ -18,21 +20,35 @@ return [
|
||||
]);
|
||||
return (object) $urls;
|
||||
},
|
||||
'permittedPaths' => [
|
||||
'/api',
|
||||
'/api/',
|
||||
],
|
||||
'simplePaths' => [
|
||||
'/api/login',
|
||||
'/api/login/',
|
||||
'/api/logout'
|
||||
],
|
||||
'externalPaths' => [
|
||||
'/api/external' => [
|
||||
'/toku/success' => [
|
||||
'validator' => Incoviba\Service\Venta\MediosPago\Toku::class,
|
||||
'token' => $_ENV['TOKU_TOKEN']
|
||||
'apiUrls' => function(ContainerInterface $container) {
|
||||
$permittedPaths = [
|
||||
'/api'
|
||||
];
|
||||
$simplePaths = [
|
||||
'/api/login',
|
||||
'/api/logout'
|
||||
];
|
||||
function addTrailingSlash(array &$paths): array {
|
||||
foreach ($paths as $path) {
|
||||
if (!in_array(rtrim($path, '/') . '/', $paths)) {
|
||||
$paths[] = rtrim($path, '/') . '/';
|
||||
}
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
addTrailingSlash($permittedPaths);
|
||||
addTrailingSlash($simplePaths);
|
||||
return [
|
||||
'permittedPaths' => $permittedPaths,
|
||||
'simplePaths' => $simplePaths,
|
||||
'externalPaths' => [
|
||||
'/api/external' => [
|
||||
'/toku/success' => [
|
||||
'validator' => Incoviba\Service\Venta\MediosPago\Toku::class,
|
||||
'token' => $container->get('TOKU_TOKEN')
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
];
|
||||
|
@ -18,9 +18,7 @@ return [
|
||||
$container->get(Incoviba\Service\API::class),
|
||||
$container->get(Incoviba\Service\Login::class),
|
||||
$container->get('API_KEY'),
|
||||
$container->get('permittedPaths'),
|
||||
$container->get('simplePaths'),
|
||||
$container->get('externalPaths'),
|
||||
$container->get('apiUrls'),
|
||||
);
|
||||
},
|
||||
Incoviba\Middleware\NotFound::class => function(ContainerInterface $container) {
|
||||
|
Reference in New Issue
Block a user