/** * Setup routing request * @param Setup $app */ public static function setupRouting(Setup $app) { $app->group('/v1', function () use($app) { // CREATE API KEY $app->post('/create-api-token', function () use($app) { $token = new APITokenAuth($app); $token->createNewToken(); }); // SAMPLE REQUEST $controller = new ExpControllerDataCustomer($app); ### GET REQUEST $app->get('/customers', function () use($controller) { $controller->getCustomers(); }); $app->get('/customer/:ID_CUSTOMER', function ($id_customer) use($controller) { $controller->getCustomers($id_customer); }); $app->get('/customer_items/:ID_CUSTOMER', function ($id_customer) use($controller) { $controller->getCustomerItems($id_customer); }); $app->get('/customer/filterby', function () use($controller) { $controller->filterCustomerBy(); }); $app->get('/customer_items/filterby', function () use($controller) { $controller->filterCustomerItems(); }); ### POST REQUEST $app->post('/customer', function () use($controller) { $controller->addNewCustomer(); }); $app->post('/customer_items', function () use($controller) { $controller->addCustomerItems(); }); ### PUT REQUEST $app->put('/customer_items/:ID_CUSTOMER', function ($id_customer) use($controller) { $controller->changeCustomerData($id_customer); }); ### DELETE REQUEST $app->delete('/customer_items/:ID_CUSTOMER', function ($id_customer) use($controller) { $controller->removeCustomer($id_customer); }); }); }
/** * Setup routing request * @param Setup $app */ public static function setupRouting(Setup $app) { $app->group('/v1', function () use($app) { // CREATE API KEY $app->post('/create-api-token', function () use($app) { $token = new APITokenAuth($app); $token->createNewToken(); }); // ControllerBukaPintu $ctrlBukaPintu = new ControllerBukaPintu($app); ### GET $app->get('/bukapintu', function () use($ctrlBukaPintu) { $ctrlBukaPintu->bukaPintu(); }); $app->get('/stopbukapintu', function () use($ctrlBukaPintu) { $ctrlBukaPintu->stopBukaPintu(); }); // ControllerAuth $ctrlAuth = new ControllerAuth($app); ### POST $app->post('/login', function () use($ctrlAuth) { $ctrlAuth->loginToGetToken(); }); $app->post('/register', function () use($ctrlAuth) { $ctrlAuth->registerNewUser(); }); ### GET $app->get('/active/:USER_ID', function ($USER_ID) use($ctrlAuth) { $ctrlAuth->userActivation($USER_ID); }); $app->get('/isexist/:EMAIL', function ($EMAIL) use($ctrlAuth) { $ctrlAuth->cekEmailIsExist($EMAIL); }); $app->get('/pending-users', function () use($ctrlAuth) { $ctrlAuth->getAllPendingUser(); }); ### DELETE $app->delete('/user/:USER_ID', function ($USER_ID) use($ctrlAuth) { $ctrlAuth->removeUser($USER_ID); }); }); }