-- dmitrybelyakov <[email protected]> wrote
(on Friday, 18 June 2010, 04:53 AM -0700):
> My application has a module, say a Blog module, with routes to it like the
> following:
> 
> /some/path/news/   (module=blog controller=index action=index)
> /some/path/news/:postAlias  (module=blog controller=post action=index)
> 
> I now need to create a REST api, so I create a Blog_RestController extending
> Zend_Rest_Contoller

<snip> 

> The problem is that I can't set Zend_Rest_Route to treat that controller as
> REST one unless I put
> the module to the top level, like the following:
> 
> That works: /blog/rest/
> That doesn't work: /some/path/news/rest/
> 
> Right now I define the REST route like this
> 
> $restRoute = new Zend_Rest_Route($front, array(), array(
>     'blog' => array('rest'),
> ));
> $router->addRoute('blog-rest', $restRoute);
> 
> Can not find anything useful in the refference, on the maling list or in
> wiki, 
> so can some one please help me with that?

This simply isn't supported currently.

Zend_Rest_Route uses defined modules + controllers to indicate
resources. Thus, if your module is "blog" and the controller "rest", it
will always use "blog/rest" as the resource end-point. It *should* honor
whatever the base URI for your application is -- I'm not sure from your
writeup if you're operating out of a subdirectory, or simply creating
aliases. If the former, you may be encountering a bug in how it detects
the current base URI. However, I suspect you're doing or wanting
aliasing, as the module name "blog" is nowhere in your desired URI path.

If you need to use an alias, which is what you're describing, you will
need to extend Zend_Rest_Route to add that functionality.

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

Reply via email to