Giter Site home page Giter Site logo

Comments (3)

evan108108 avatar evan108108 commented on July 26, 2024

The problem is that RESTFullYii expects api/<controller> and you are sending api/my/<controller> . In order to resolve this you will need to add some routes something like the routes bellow:

//Add these (NOT TESTED).
        'api/my/<controller:\w+>'=>['my/<controller>/REST.GET', 'verb'=>'GET'],
        'api/my/<controller:\w+>/<id:\w*>'=>['my/<controller>/REST.GET', 'verb'=>'GET'],
        'api/my/<controller:\w+>/<id:\w*>/<param1:\w*>'=>['my/<controller>/REST.GET', 'verb'=>'GET'],
        'api/my/<controller:\w+>/<id:\w*>/<param1:\w*>/<param2:\w*>'=>['my/<controller>/REST.GET', 'verb'=>'GET'],

        ['my/<controller>/REST.PUT', 'pattern'=>'api/my/<controller:\w+>/<id:\w*>', 'verb'=>'PUT'],
        ['my/<controller>/REST.PUT', 'pattern'=>'api/my/<controller:\w+>/<id:\w*>/<param1:\w*>', 'verb'=>'PUT'],
        ['my/<controller>/REST.PUT', 'pattern'=>'api/my/<controller:\w*>/<id:\w*>/<param1:\w*>/<param2:\w*>', 'verb'=>'PUT'],        

        ['my/<controller>/REST.DELETE', 'pattern'=>'api/my/<controller:\w+>/<id:\w*>', 'verb'=>'DELETE'],
        ['my/<controller>/REST.DELETE', 'pattern'=>'api/my/<controller:\w+>/<id:\w*>/<param1:\w*>', 'verb'=>'DELETE'],
        ['my/<controller>/REST.DELETE', 'pattern'=>'api/my/<controller:\w+>/<id:\w*>/<param1:\w*>/<param2:\w*>', 'verb'=>'DELETE'],

        ['my/<controller>/REST.POST', 'pattern'=>'api/my/<controller:\w+>', 'verb'=>'POST'],
        ['my/<controller>/REST.POST', 'pattern'=>'api/my/<controller:\w+>/<id:\w+>', 'verb'=>'POST'],
        ['my/<controller>/REST.POST', 'pattern'=>'api/my/<controller:\w+>/<id:\w*>/<param1:\w*>', 'verb'=>'POST'],
        ['my/<controller>/REST.POST', 'pattern'=>'api/my/<controller:\w+>/<id:\w*>/<param1:\w*>/<param2:\w*>', 'verb'=>'POST'],

from restfullyii.

rkranjith avatar rkranjith commented on July 26, 2024

Evan,

Thanks for the reply.

I have updated the routers, but i getting the same 404 error.

I have tried changing your code, it works for me. Instead of sending api/my/<controller> should send my/api/<controller>.

Now the problem was i have many sub-folders in the controllers. It is very difficult to create & manage routers for many folders.

Is there way to specify multiple folder names?

Thanks in advance.

from restfullyii.

evan108108 avatar evan108108 commented on July 26, 2024

Well I am glad you got it working. Are these controllers in modules? If so you might be able to do something like /api/. Other then that there is not a lot I can do without making a routes class which I am loath to do because I would rather put the control (for use-cases just like this) in your hands.

If these controllers are not module; can I ask why they are in subfolders?

from restfullyii.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.