|
@@ -34,34 +34,27 @@ $authHmac = new HmacAuthMiddleware();
|
|
|
$authJwt = new JWTAuthMiddleware();
|
|
$authJwt = new JWTAuthMiddleware();
|
|
|
$cors = new CorsControl();
|
|
$cors = new CorsControl();
|
|
|
|
|
|
|
|
-// Função para envolver rotas com CORS
|
|
|
|
|
-$withCors = function ($handler) use ($cors) {
|
|
|
|
|
- return function (ServerRequestInterface $request) use ($handler, $cors) {
|
|
|
|
|
- return $cors($request, $handler);
|
|
|
|
|
- };
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
// Rotas com CORS aplicado
|
|
// Rotas com CORS aplicado
|
|
|
-$app->get('/hmachelloworld', $withCors($authHmac), \Controllers\HelloController::class);
|
|
|
|
|
|
|
+$app->get('/hmachelloworld', $cors, $authHmac, \Controllers\HelloController::class);
|
|
|
|
|
|
|
|
-$app->get('/jwthelloworld', $withCors($authJwt), \Controllers\HelloController::class);
|
|
|
|
|
|
|
+$app->get('/jwthelloworld', $cors, $authJwt, \Controllers\HelloController::class);
|
|
|
|
|
|
|
|
|
|
|
|
|
//Rotas User
|
|
//Rotas User
|
|
|
-$app->post('/login', $withCors(\Controllers\LoginController::class));
|
|
|
|
|
-$app->post('/register', $withCors(\Controllers\RegisterController::class));
|
|
|
|
|
|
|
+$app->post('/login', $cors, \Controllers\LoginController::class);
|
|
|
|
|
+$app->post('/register', $cors, $authJwt, \Controllers\RegisterController::class);
|
|
|
|
|
|
|
|
//Rotas Category
|
|
//Rotas Category
|
|
|
-$app->post('/category/get', $withCors(\Controllers\CategoryGetController::class) );
|
|
|
|
|
-$app->post('/category/create', $withCors(\Controllers\CategoryCreateController::class) );
|
|
|
|
|
-$app->post('/category/delete', $withCors(\Controllers\CategoryDeleteController::class) );
|
|
|
|
|
-$app->post('/category/add-product', $withCors(\Controllers\CategoryAddProductController::class) );
|
|
|
|
|
|
|
+$app->post('/category/get', $cors, \Controllers\CategoryGetController::class);
|
|
|
|
|
+$app->post('/category/create', $cors, $authJwt, \Controllers\CategoryCreateController::class);
|
|
|
|
|
+$app->post('/category/delete', $cors, $authJwt, \Controllers\CategoryDeleteController::class);
|
|
|
|
|
+$app->post('/category/add-product', $cors, $authJwt, \Controllers\CategoryAddProductController::class);
|
|
|
|
|
|
|
|
//Rotas Product
|
|
//Rotas Product
|
|
|
-$app->post('/product/get', $withCors(\Controllers\ProductGetController::class));
|
|
|
|
|
-$app->post('/product/create', $withCors(\Controllers\ProductCreateController::class));
|
|
|
|
|
-$app->post('/product/update', $withCors(\Controllers\ProductUpdateController::class));
|
|
|
|
|
-$app->post('/product/delete', $withCors(\Controllers\ProductDeleteController::class));
|
|
|
|
|
|
|
+$app->post('/product/get', $cors, $authJwt, \Controllers\ProductGetController::class);
|
|
|
|
|
+$app->post('/product/create', $cors, $authJwt, \Controllers\ProductCreateController::class);
|
|
|
|
|
+$app->post('/product/update', $cors, $authJwt, \Controllers\ProductUpdateController::class);
|
|
|
|
|
+$app->post('/product/delete', $cors, $authJwt, \Controllers\ProductDeleteController::class);
|
|
|
|
|
|
|
|
$app->run();
|
|
$app->run();
|