$app->post('/avatar', function () { if (accessIsOK()) { $request = \Slim\Slim::getInstance()->request(); $userAuth = json_decode($request->headers->get('Authorization')); $avatar = json_decode($request->getBody()); $avatarService = new AvatarService(); echo json_encode($avatarService->save($avatar, $userAuth->id)); } }); $app->group('/user', function () use($app) { $app->get('/level', function () { if (accessIsOK()) { $request = \Slim\Slim::getInstance()->request(); $userAuth = json_decode($request->headers->get('Authorization')); $profileService = new ProfileService(); echo json_encode($profileService->getUserLevel($userAuth->id)); } }); $app->get('/score', function () { if (accessIsOK()) { $request = \Slim\Slim::getInstance()->request(); $userAuth = json_decode($request->headers->get('Authorization')); $profileService = new ProfileService(); echo json_encode($profileService->getTotalScore($userAuth->id)); } }); $app->get('/maxlevel', function () { if (accessIsOK()) { $profileService = new ProfileService(); echo json_encode($profileService->getMaxLevel()); }