Routing with API

2011-02-07 Thread tnbrooks
I orginally added the resources for models in my routes file to create
an api for my app.
Router::mapResources('users');
Router::mapResources('topics');
.
As well as the extension parser
Router::parseExtensions();

I'd like to have a web app and an api from the same app so have
created a prefix for my api:
Router::connect('/api/:controller/:action/*', array('prefix' = 'api',
'api' = true));

Now when I go to http://localhost/webapp/api/users the index displays
fine, however if I go to http://localhost/webapp/api/users/1 it no
longer displays the user with id 1 as it did when I didn' have the
prefix.  Have i done something wrong or is this a known issue? The
error I am getting is this:
Error: The requested address '/api/users/1' was not found on this
server.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Routing with API

2011-02-07 Thread Ryan Schmidt

On Feb 7, 2011, at 22:23, tnbrooks wrote:

 I'd like to have a web app and an api from the same app so have
 created a prefix for my api:
 Router::connect('/api/:controller/:action/*', array('prefix' = 'api',
 'api' = true));
 
 Now when I go to http://localhost/webapp/api/users the index displays
 fine, however if I go to http://localhost/webapp/api/users/1 it no
 longer displays the user with id 1 as it did when I didn' have the
 prefix.  Have i done something wrong or is this a known issue? The
 error I am getting is this:
 Error: The requested address '/api/users/1' was not found on this
 server.

Don't you need:

http://localhost/webapp/api/users/view/1


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Routing with API

2011-02-07 Thread tnbrooks
Sorry meant to say that workshowever if I don't have the prefix
set, then it works fine with out the view however the prefix stops the
magic from happening.
assume the only way is to see if there is not id given and from there,
show all else, get the user with the specific id?

On Feb 8, 3:57 pm, Ryan Schmidt google-2...@ryandesign.com wrote:
 On Feb 7, 2011, at 22:23, tnbrooks wrote:

  I'd like to have a web app and an api from the same app so have
  created a prefix for my api:
  Router::connect('/api/:controller/:action/*', array('prefix' = 'api',
  'api' = true));

  Now when I go tohttp://localhost/webapp/api/usersthe index displays
  fine, however if I go tohttp://localhost/webapp/api/users/1it no
  longer displays the user with id 1 as it did when I didn' have the
  prefix.  Have i done something wrong or is this a known issue? The
  error I am getting is this:
  Error: The requested address '/api/users/1' was not found on this
  server.

 Don't you need:

 http://localhost/webapp/api/users/view/1

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php