- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
This commit is contained in:
43
app/Providers/CorsServiceProvider.php
Normal file
43
app/Providers/CorsServiceProvider.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Data\Validation\NetteValidator;
|
||||
use App\Data\Validation\ValidatesArray;
|
||||
use App\Services\CorsService;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Nette\Schema\Expect;
|
||||
use Nette\Schema\Schema;
|
||||
|
||||
class CorsServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->when(CorsService::class)
|
||||
->needs(ValidatesArray::class)
|
||||
->give(fn () => static::determineConfigValidator());
|
||||
}
|
||||
|
||||
private static function determineConfigValidator(): ValidatesArray
|
||||
{
|
||||
return new NetteValidator(
|
||||
new \Nette\Schema\Processor(),
|
||||
static::getConfigValidationSchema(),
|
||||
);
|
||||
}
|
||||
|
||||
private static function getConfigValidationSchema(): Schema
|
||||
{
|
||||
return Expect::structure([
|
||||
'path' => Expect::string(),
|
||||
'origin' => Expect::string()->nullable(),
|
||||
'methods' => Expect::arrayOf(Expect::string()),
|
||||
'headers' => Expect::arrayOf(Expect::string()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user