|
|
@@ -41,42 +41,25 @@ $withCors = function ($handler) use ($cors) {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-// Função para lidar com requisições OPTIONS
|
|
|
-$handleOptions = function (ServerRequestInterface $request) {
|
|
|
- $corsHeaders = [
|
|
|
- 'Access-Control-Allow-Origin' => '*',
|
|
|
- 'Access-Control-Allow-Methods' => '*',
|
|
|
- 'Access-Control-Allow-Headers' => '*'
|
|
|
- ];
|
|
|
- return new Response(200, $corsHeaders);
|
|
|
-};
|
|
|
|
|
|
// Rotas com CORS aplicado
|
|
|
$app->get('/hmachelloworld', $withCors($authHmac), \Controllers\HelloController::class);
|
|
|
-$app->options('/hmachelloworld', $handleOptions);
|
|
|
|
|
|
$app->get('/jwthelloworld', $withCors($authJwt), \Controllers\HelloController::class);
|
|
|
-$app->options('/jwthelloworld', $handleOptions);
|
|
|
|
|
|
|
|
|
//Rotas User
|
|
|
$app->post('/login', $withCors(\Controllers\LoginController::class));
|
|
|
-$app->options('/login', $handleOptions);
|
|
|
$app->post('/register', $withCors(\Controllers\RegisterController::class));
|
|
|
-$app->options('/register', $handleOptions);
|
|
|
|
|
|
//Rotas Category
|
|
|
$app->get('/category', $withCors(\Controllers\CategoryController::class));
|
|
|
$app->post('/category', $withCors(\Controllers\CategoryController::class));
|
|
|
-$app->options('/category', $handleOptions);
|
|
|
$app->post('/category/delete', $withCors(\Controllers\CategoryController::class));
|
|
|
-$app->options('/category/delete', $handleOptions);
|
|
|
$app->post('/category/add-product', $withCors(\Controllers\CategoryController::class));
|
|
|
-$app->options('/category/add-product', $handleOptions);
|
|
|
|
|
|
//Rotas Product
|
|
|
$app->get('/product', $withCors(\Controllers\ProductController::class));
|
|
|
$app->post('/product', $withCors(\Controllers\ProductController::class));
|
|
|
-$app->options('/product', $handleOptions);
|
|
|
|
|
|
$app->run();
|