0

I have this code on Restler and it returns 404 Not Found

class CRUDEntity {
  /**
   * @url GET /entity/{entity_id}/books/*
   */    
  function getBatch($entity_id) {
    var_dump(func_get_args());
  }
}

On the index page I have the following:

$r->addAPIClass('CRUDEntity','');

The idea is to get into the url /entity/1/books/10/12/13/14 but it returns the 404 error. Do you know how can I accomplish this?

1 Answers1

0

Wildcard routes do not support dynamic parts yet! so you can do the following instead

class CRUDEntity
{
    /**
     * @param int $entity_id
     *
     * @url GET /entity/*
     */
    function getBatch($entity_id, $books = 'books')
    {
        if (!is_numeric($entity_id) || $books != 'books') {
            throw new RestException(404);
        }
        $dynamicArguments = func_get_args();
        array_shift($dynamicArguments);
        array_shift($dynamicArguments);
        var_dump($dynamicArguments);
    }
}
Arul Kumaran
  • 983
  • 7
  • 23
  • Thank you, I solved the issue using an approach similar of what you mentioned. Its great to see this kind of framework with a lot of options. – Miguel González Jan 12 '15 at 18:27