New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for longer (or more complex) URLs #15
Comments
You can use routes. For example create a specific route per URL in .../module/Main/configs/module.config.php:
Create the StatusesController where the above URLs are now mapped. In the StatusesController and within the target HTTP method sniff the route name and act appropriately:
I suggest using the controller just to sniff the route and then redirect code flow to some sort of library code to keep your controllers light. Let me know if you have more questions. |
Thanks for the quick response. I somehow focused to much on the predefined routes in the module, instead of thinking about custom routing. :) |
What's a guy to do if he wants, I used your stock module.config.php and got the account and account/accountID stuff going but i'm not sure how to set up the child_routes (do i even want to use that?). I'm not sure how (or if they can) they co-exist with options stuff in the main route. Like, how does the application know it's an account id or a route to travel. Yeesh, this stuff is over my head. |
@daveo1001 RTFM? :) -- http://framework.zend.com/manual/2.0/en/modules/zend.mvc.routing.html -- "Like, how does the application know it's an account id or a route to travel." |
I had. It left me more confused than when I started. |
I am having a similar issue as @daveo1001. I am try to do a nested call /object/id/nestedobject[/:id] but the request is always going to the get action on the nested controller. I am guessing because the first id is set. So how would you go about doing a nested rest route? 'nvpapicalls-rest' => array(
'type'=>'Segment',
'options' => array(
'route' => '/nvpapicalls[.:formatter][/:id]',
'constraints' => array(
'formatter' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'nvpapicalls-rest',
),
),
'may_terminate' => true,
'child_routes' => array(
'comments' => array(
'type'=>'Segment',
'options' => array(
'route' => '/comments[/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'nvpcomments-rest',
//'action' => 'list'
),
),
),
),
), When i go to /nvpapicalls.json/10/comments it is being dispatched to the nvpcomments-rest controller but to the get action and not the getList action. Any idea? Update: Found a work around. I just changed the :id to :commentid and used $this->setIdentifierName('commentid'); in the construct of the controller. Anyone know if there is a routing configuration option for this? |
hi how can i access the create method using your restful APi thanks real need it i am new to restful using zf2 thanks iam using jquery mobile by the way in ajax request please help me |
Hi,
I am looking into supporting more fine-grained URLs, for example like the Twitter API:
statuses/mentions_timeline
statuses/user_timeline
Is this something you can help me with or point me in the right direction?
Regards,
Daan
The text was updated successfully, but these errors were encountered: