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

Best way to get the current resource name #1762

Open
seguidor777 opened this issue Aug 13, 2019 · 1 comment

Comments

@seguidor777
Copy link

commented Aug 13, 2019

Hello,

I am working on a feature that uses policies to authorize requests basing on a user role, an action and a resource.

I have no problem to get the first two, but I am facing issues with getting the resource name, since I only have the full path. Is there any efficient way to get that with any function similar to controller_name from Rails?

@seguidor777

This comment has been minimized.

Copy link
Author

commented Aug 13, 2019

I could extract the resource name from the name of the handler, for example:
handlerName: = c.Data()["current_route"].(buffalo.RouteInfo).HandlerName

Lets suppose that handlerName is something like "github.com/company/project/actions.UsersResource.Edit"
And with some regexp stuff I capture the UsersResource string, but this does not convince me at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.