$u = (string) $input->userid; $id = $us->updateUsers($input, $u); echo json_encode($id); } catch (Exception $e) { throw new Exception($e->getMessage()); } }); $app->delete('/delmember/:id(/)', 'authenticate', function ($id) use($app) { try { $us = new UsersService(); $request = $app->request(); $mediaType = $request->getMediaType(); $body = $request->getBody(); $input = json_decode($body, TRUE); $u = (string) $input['userid']; $id = $us->deleteUsers($id, $u); echo json_encode($id); } catch (Exception $e) { throw new Exception($e->getMessage()); } }); // $app->get('/login/:id', 'authenticate', function ($id) use ($app) { // try { // $us = new UsersService(); // $user = $us->getUsersByID($id); // if($user){ // echo json_encode($user); // } else { // throw new ResourceNotFoundException(); // } // } catch (ResourceNotFoundException $e) {
// } // } else if($request[0] == ''){ // $rs = $sv->function($request[1],$user); // echo json_encode($rs); // } else { // } } else { if (empty($request[0])) { echo json_encode($sv->getAllUsers($user)); } else { echo json_encode($sv->getUsersByID($request[0], $user)); } } break; case 'DELETE': try { if (!empty($request[0])) { $rs = $sv->deleteUsers($request[0], $user); echo json_encode($rs); } else { throw new Exception('No Id for Delete'); } } catch (Exception $e) { http_response_code(500); echo $e->getMessage(); //throw new Exception($e->getMessage()); } break; default: break; }