title: CakePHP router cannot parse POST methods
body: <p>I'm developing a CakePHP plugin which will be a Rest API kit and POST routes are not being parsed.</p>
  
  <h2><strong>Routing</strong></h2>
  
  <p>The problem is: <code>Router::connect</code> is not parsing any action with a different method than GET. </p>
  
  <p>I would like to apply the common Rest routes like:</p>
  
  <pre><code>GET      /api/products       Get all products
  GET      /api/products/:id   Get a single product
  POST     /api/products       Create a product
  PUT      /api/products/:id   Update a product
  DELETE   /api/products/:id   Delete a product
  </code></pre>
  
  <p>I wouldn't like to use <code>Router::mapResource</code> to do that so I tried this:</p>
  
  <pre><code>// app/Config/core.php
  Configure::write('Routing.prefixes', array('api')); 
  
  // app/Config/bootstrap.php
  CakePlugin::load('MY_PLUGIN', array('routes' =&gt; true));
  
  // app/Config/routes.php
  Router::parseExtensions('json');
  
  // app/Plugin/MY_PLUGIN/Config/routes.php
  
  Router::connect(
      '/api/:controller',
      array(
          'prefix' =&gt; 'api',
          'api' =&gt; true,
          'action' =&gt; 'index',
          'method' =&gt; 'GET',
      )
  );
  
  Router::connect(
      '/api/:controller/:id',
      array(
          'prefix' =&gt; 'api',
          'api' =&gt; true,
          'action' =&gt; 'view',
          'method' =&gt; 'GET',
      )
  );
  
  Router::connect(
      '/api/:controller',
      array(
          'prefix' =&gt; 'api',
          'api' =&gt; true,
          'action' =&gt; 'add',
          'method' =&gt; 'POST',
      )
  );
  </code></pre>
  
  <p>I created a simple controller just to test it:</p>
  
  <pre><code>// app/Controller/ProductsController.php
  public function api_index() {
      die('api_index');
  }
  
  public function api_view($id = null) {
      die('api_view');
  }
  
  public function api_add() {
      die('api_add');
  }
  </code></pre>
  
  <p>Here's a list of responses that I get:</p>
  
  <pre><code>GET   /api/products      "api_index"
  GET   /api/products/:id  "api_view"
  POST  /api/products      "api_index"
  </code></pre>
  
  <p>Notice that the POST action couldn't find a proper route that match it. Anyone can explain it to me and knows a good solution for that?</p>
  
  <p>Here's a list of questions that I already tried:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/17737281/cakephp-restful-routes">CakePHP restful routes</a></li>
  <li><a href="https://stackoverflow.com/questions/25019437/cakephp-rest-route-does-not-work">CakePHP REST route does not work</a></li>
  </ol>