Example #1
0
         $res = $res->withStatus(200);
     });
     $app->post('/{id:[0-9]+}/group/{gid:[0-9]+}', function ($req, $res, $arg) use($model) {
         $res->getBody()->write(json_encode(array('status' => $model->assignNoteToGroup($arg['id'], $arg['gid']))));
         $res = $res->withHeader('Content-type', 'application/json');
         $res = $res->withStatus(200);
     });
     $app->delete('/{id:[0-9]+}/group/{gid:[0-9]+}', function ($req, $res, $arg) use($model) {
         $res->getBody()->write(json_encode(array('status' => $model->removeNoteFromGroup($arg['id']))));
         $res = $res->withHeader('Content-type', 'application/json');
         $res = $res->withStatus(200);
     });
 });
 $app->group('/groups', function () use($app, $model) {
     $app->get('/', function ($req, $res, $arg) use($model) {
         $res->getBody()->write(json_encode($model->showGroups()));
         $res = $res->withHeader('Content-type', 'application/json');
         $res = $res->withStatus(200);
     });
     $app->get('/{gid:[0-9]+}', function ($req, $res, $arg) use($model) {
         $res->getBody()->write(json_encode($model->showGroup($arg['gid'])));
         $res = $res->withHeader('Content-type', 'application/json');
         $res = $res->withStatus(200);
     });
     $app->post('/', function ($req, $res, $arg) use($model) {
         $status = $model->createGroup($req->getParams());
         $res->getBody()->write(json_encode(array('status' => $status == 0 ? false : true)));
         $res = $res->withHeader('Content-type', 'application/json');
         $res = $res->withStatus(200);
     });
     $app->put('/{gid:[0-9]+}', function ($req, $res, $arg) use($model) {