Skip to content
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

Expose Custom Methods #68

Open
zegerman opened this issue Mar 13, 2016 · 3 comments
Open

Expose Custom Methods #68

zegerman opened this issue Mar 13, 2016 · 3 comments

Comments

@zegerman
Copy link

Hi,

thank you for the module. Its working great so far.

However I would like to make custom methods (e.g. of Controllers) accessible via REST.

Can this be done as well?

I see that something can be done with api/acl/ but not sure how this can be configured.

Thx
Andy

@TihoBeretovac
Copy link

I would also like to get a handle on the custom method execution.
From the code - it defers the method to the allowed_actions within the $authority (which by default is the RESTful_API_DefaultPermissionManager. Is that by design? The permission manager is responsible for delegating out the actions/methods to their final destination?

@sanderha
Copy link

I'd like some help with this aswell

@colymba
Copy link
Owner

colymba commented Aug 9, 2017

@zegerman @TihoBeretovac @sanderha sorry for not replying earlier...

it all depends what you are trying to achieve... if you have methods on some Controller you had like to access, this is already built in SS, you should be able to access it through the route ControllerName/method or setup a custom route to use something else than the controller name in the route.

If you want the result of your custom method to be serialized, you can always instantiate the Serializer in your custom method.

if you want your Controller methods to be accessed through the api/... route. This will need more work. You would have to extend the main API class with your own and edit the config of the new RESTfulAPI class, adding your own entry in $dependencies and the public property that match so the controller is instantiated. Then also add your own entry in allowed_actions and url_handlers. Then create the method that match your definition on url_handlers to access your controller and pass on the request to your own controller where the method is.... so overall, more complicated.

@TihoBeretovac the permission manager is used to check is the user accessing the api has the right to read, edit etc the model being accessed. Through the canView etc methods. Nothing more at the moment. The acl method on RestfulAPI is there just in case, for example if someone create a custom permission manager and needs to access some methods on it via the api. But at the minute or with the default, it's not in use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants