title: ZF2 Restful API not routing options method
body: <p>I am testing my zf2 restful api by sending an OPTIONS command to it but its going right into the action defined in the router and not the options() method. </p>
  
  <p>Router:</p>
  
  <pre><code>'router' =&gt; array(
      'routes' =&gt; array(
          'edatafeed' =&gt; array(
              'type'    =&gt; 'Zend\Mvc\Router\Http\Literal',
              'options' =&gt; array(
                  'route'    =&gt; '/api',
                  'defaults' =&gt; array(
                      '__NAMESPACE__'    =&gt; 'Application\Controller',
                  ),
              ),
              'may_terminate' =&gt; true,
              'child_routes' =&gt; array(
                  'default' =&gt; array(
                      'type'    =&gt; 'Segment',
                      'options' =&gt; array(
                          'route'    =&gt; '/:controller[/:action][/]',
                          'constraints' =&gt; array(
                              'controller' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                          ),
                          'defaults' =&gt; array(
                          ),
                      ),
                  ),
              ),
          ),
      ),
  ),
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>class SomeController extends ApiController
  {
      protected $dm;
  
      private function getDm()
      {
          $this-&gt;dm = $this-&gt;getServiceLocator()-&gt;get('doctrine.documentmanager.odm_default');
      }
  
      public function executeAction()
      {
          return new JsonModel(array(
              'ok' =&gt; false,
              'data' =&gt; null,
          ));
      }
  }
  </code></pre>
  
  <p>ApiController:</p>
  
  <pre><code>class ApiController extends AbstractRestfulController
  {
  
      protected function methodNotAllowed()
      {
          $this-&gt;response-&gt;setStatusCode(405);
          throw new \Exception('Method Not Allowed');
      }
  
      public function options()
      {
          $response = $this-&gt;getResponse();
          $headers  = $response-&gt;getHeaders();
  
          $headers-&gt;addHeaderLine('Allow', implode(',', array(
              'GET',
              'POST',
          )))
          -&gt;addHeaderLine('Content-Type','application/json; charset=utf-8');
          return $response;
      }
  }
  </code></pre>
  
  <p>When I sent an OPTIONS command to /api/some/execute it goes right into the execute action and not into the options method. Is there something I'm missing in the routing? I thought that sending any OPTIONS command would route it to options().</p>
  
  <p>Thanks</p>