Ejemplo n.º 1
0
         $res->getBody()->write(json_encode(array('status' => $model->editNote(json_decode($req->getBody(), true)))));
         $res = $res->withHeader('Content-type', 'application/json');
         $res = $res->withStatus(200);
     });
     $app->delete('/{id:[0-9]+}', function ($req, $res, $arg) use($model) {
         $res->getBody()->write(json_encode(array('status' => $model->deleteNote($arg['id']))));
         $res = $res->withHeader('Content-type', 'application/json');
         $res = $res->withStatus(200);
     });
     $app->get('/{id:[0-9]+}/group/', function ($req, $res, $arg) use($model) {
         $res->getBody()->write(json_encode($model->showNote($arg['id'])));
         $res = $res->withHeader('Content-type', 'application/json');
         $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);
     });