public function indexAction(Request $request)
 {
     $this->request = $request;
     $this->response = $this->container['response'];
     // Set supported request methods
     $this->request->setSupportedRequestMethods(array(Request::GET, Request::POST, Request::PUT, Request::DELETE));
     // Set supported content types
     $this->request->setSupportedContentTypes(array(Request::APPLICATION_JSON_CONTENT_TYPE));
     // Check if passed requested method is supported
     if (!$this->request->isRequestMethodSupported()) {
         echo $this->response->sendJson(Response::METHOD_NOT_ALLOWED_CODE);
         die;
     }
     switch ($this->request->getRequestMethod()) {
         case Request::GET:
             echo $this->getPosts($request->getParam('id'));
             break;
         case Request::POST:
             echo $this->createPost();
             break;
         case Request::PUT:
             echo $this->updatePost($request->getParam('id'));
             break;
         case Request::DELETE:
             echo $this->deletePost($request->getParam('id'));
             break;
     }
 }